Skip to main content
10 events
when toggle format what by license comment
Feb 12, 2017 at 7:13 vote accept Yves Schelpe
Feb 11, 2017 at 16:15 comment added Joppe @Yves Schelpe ToString() is fine if assists debugging or perhaps inclusion in log file entries. Or if it is on basic value objects only if there is one obvious 'default' you could do. But typically you want to defer how you present something till the last moment, the presentation layer or view model you are projecting into.
Feb 11, 2017 at 15:37 comment added Yves Schelpe @Joppe: True, very true, I got confused by the comments I think. I will remove it and change it back. Thanks for the constructive thinking and feedback. PS: what about toString() and ToString() in js and C# - are they considered then "in pure theorethical form", bad design, not?
Feb 11, 2017 at 13:54 comment added Joppe @Yves Schelpe Format is now only delegating without adding anything, it's screaming at you: "this responsibility should not go here!" :-) Formatting is a presentation concern, you shouldn't put it in your entity.
Feb 11, 2017 at 13:47 comment added Yves Schelpe @Joppe - I initially thought so too, but I understand it's maybe a bit contrived and complex - however it is my intention to build on it.. I changed it now to this: github.com/learnasyougo/S.O.L.I.D#openclosed-principle - where I left in the format method, but made sure the details of the implementation are extracted.. So that later on I can introduce the notion of Interface Segragation principle as well, and add "IFormattable" for example on the Person class..?
Feb 11, 2017 at 13:37 comment added Joppe The class has two reasons to change, the shape and behavior of a person and the formats it's supposed to support. I think this IS a good example of SRP.
Feb 11, 2017 at 13:31 comment added Yves Schelpe maybe I should keep the Format method, introduce and IFormatter as parameter .. ? And later on I can build on the "Interface Segragation" and leave off the Format method and introduce IFormattable - which then holds format(IFormatter fromatter);
Feb 11, 2017 at 13:29 vote accept Yves Schelpe
Feb 11, 2017 at 13:43
Feb 11, 2017 at 13:25 comment added Yves Schelpe I agree, I'm just trying to build up an example that will go along an applies all SOLID principles to a bad example / violation(s)... - As you said yourself, where the SRP comes into play - I try to seperate it already... But maybe I should first keep it simple, and later on come up with an example that's bigger / complexer. I'll revise this. Thannks for the advice.
Feb 11, 2017 at 13:21 history answered Bent CC BY-SA 3.0