Note that there are some explanatory texts on larger screens.

plurals
  1. PORepository pattern using PowerShell
    primarykey
    data
    text
    <p>Here is my concern,</p> <p>My problem is not really with PowerShell, but the way I have to use it to implement the persistence. I often get cases where there is more than 4 commands to do the logic or to apply persistence.</p> <p>For example: </p> <p>When configuring a Dns Zone, I get the normal New/Get/Set/Remove-DnsZone <strong>and</strong> Suspend/Unsuspend-DnsZone. How my teammates are currently handling it is that they make an extra method on the repository to handle the extra commands.</p> <p>It seems to me like the behavior should instead be on the object and that Suspend/Unsuspend-DnsZone should be called when Create or Update is executed on the repo. </p> <p>What do you think?</p> <hr> <p><strong>EDIT</strong> As requested, I'll put some code to demonstrate what I am talking about.</p> <p>This is a fake example with an almost similar implementation of our Powershell wrapper. This is a method on the repository that my teammates do:</p> <pre><code>public void Suspend(DnsZone zone) { _powerShell.Execute("Suspend-Zone", new Dictionary&lt;string, object&gt;{{"Name", zone.Name}}); } </code></pre> <p>So somewhere in your logic, to suspend a zone you have to call </p> <pre><code>var myZone = new DnsZone{ Name= "xyz"}; _zones.Suspend(myZone); </code></pre> <p>Instead, what I prone is that DnsZone should have a property or a method. So that the logic is not in the repo but in the object itself. Even though the repo has to translate that into a Suspend-Zone call.</p> <pre><code>var myZone = _zones.FindByName("nyname"); myZone.Suspend(); _zones.Save(myZone); </code></pre> <p>hth</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload