-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should we use a PS Classe as a core framework of the module ? #7
Comments
Cons: Won't work prior to PS5 👎 |
My personnal, very personnal opinion : i prefer ps3+ modules. |
example of PS Class for log (provided by @LxLeChat Class Log {
$LogPath = $null
Log ([String]$a){
if ( !(test-path $a) ) {
New-Item -Path $a -ItemType file
$this.LogPath = $a
} else {
$this.LogPath = $a
}
}
Log ([String]$a,[Bool]$FileTimeStamp){
$leaf = $(get-date -Format "ddMMyyyy_hhmmss") + "_" + $(split-path $a -Leaf)
$path = Join-Path -Path (split-path $a) -ChildPath $leaf
if ( !(test-path $path) ) {
New-Item -Path $path -ItemType file
$this.LogPath = $path
} else {
$this.LogPath = $path
}
}
Log () {}
[void] WriteMessage ([String]$m, [Bool]$n){
If ( $this.LogPath -ne $null ) {
If ( $n ) {
$(get-date -Format "dd/MM/yyyy hh:mm:ss") + ' - ' + $m >> $this.LogPath
} else {
$m >> $this.LogPath
}
}
}
}
$true represent the timestamp at the beginning of the line |
I would like to use classes just to learn classes and for maintainability. |
Classes add flexibility. For example, you instantiate a new log file (wich contains properties and methods) then you can simply call the methods you like on this log file. downside like said before: ps version. |
I think it would be interesting to look at classes too. |
non mais les gars, bous en managez bcp des servers encore qui ont pas plus haut que ps3? Et franchement si c'est le cas, y a pas un pb de lifecycle quelque part? |
et donc pr repondre finalement a la question de l'issue: De plus, c'est l'occasion idéale pour apprendre / approfondir les classes pr la communauté Française. Pr moi, la version ps est un faux prétexte, et n'est pas une raison valide pour écrire du 'légacy' code. |
No description provided.
The text was updated successfully, but these errors were encountered: