424 reputation
210
bio website
location
age
visits member for 3 years
seen 22 hours ago

1d
comment In MVC, who is in charge of handling observers?
If you use a real object rather than objectA, say engineTemperature, then your view that displays the temperature would surely know what it's displaying. It's normal for views to be coupled to the model elements they display. The other way around, however, is different. engineTemperature should not know how it's being displayed, or who's displaying it, etc. It (as a Subject in the Observer pattern) only knows it has Observers, which all support the Observer API. Have a look at martinfowler.com/eaaDev/uiArchs.html#ModelViewController
1d
comment In MVC, who is in charge of handling observers?
MVC isn't about total decoupling. It's about avoiding coupling to elements that are unstable. Views tend to be less stable than the model, because they're the UI (users tend to want new ways to view, etc.) E.g. how many times the GUI for Microsoft Word has changed, yet the model of a document has not changed much. Views are directly coupled to the model classes because they're more stable. Model classes are coupled to views via the Observer pattern. The Observer API is very stable, even if the views that implement it are not. So it's OK to have coupling the way you have described it.
1d
comment In MVC, who is in charge of handling observers?
I disagree with @RobertHarvey in that MVC Views are often Observers of Model classes. The patterns are indeed related; one isn't required to use Observer with MVC, however.
1d
comment In MVC, who is in charge of handling observers?
We've now coupled the View into the internals of the Model, which I believe violates the Law of Demeter. I'm pretty sure this also violates the concept of MVC by definition. The second point is wrong. Views do know the model. By definition, view code changes more often, so you don't want model code being coupled to it directly. As for Law of Demeter, you'd have to show why you think it violates it. It's not a hard and fast principle, either, despite it's name having the word "Law" in it. It's nearly impossible not to violate it at some point.
Apr
10
comment Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?
A UML sequence diagram would be helpful to see the flow.
Apr
10
comment Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?
There's a convention in Eclipse Java to use internal path for having private methods that should not be used by external classes. However, I'm not sure it solves your problem since Message can't be both internal and not (for the methods people should call).
Feb
14
comment Possible way to make java class builder more abstract by using interface required keys
Related blog explaining this builder/required technique: blog.crisp.se/2013/10/09/perlundholm/…
Feb
5
comment How to add permissions checks 'after the fact'
I think this is a great answer because it points out the trade-off between flexibility and the added complexity (obscurity) of a design pattern.
Feb
4
comment One controller to rule them all?
I would also not try to come up with your own way, before checking out recommended ways. Google found me this tutorial: pluralsight.com/training/…
Feb
4
comment One controller to rule them all?
Re: #2, I would spend time on real security and not on security by obscurity.
Jan
28
comment Does functional programming increase the 'representational gap' between problems and solutions?
Your analogy with 30 students is interesting, but I doubt that your "Java class" taught you an analysis/design/methodology (ADM), eg. CRC cards, or that it was followed by all 30 students. My first OO class in Ada (1984) used the Booch method and our solutions all had the same high-level design. Classes were the nouns in the problem statement given to us by the instructor. Decreasing representational gap requires following a good ADM. One of the edits I made cites a paper from 2004 that says FP potentially lacks abstractions suited to real-world, supporting #4.
Jan
27
comment Does functional programming increase the 'representational gap' between problems and solutions?
@paul Thanks for those refs, very constructive feedback.
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
@itsbruce I realize FP is much more than C. The question is about how is it easy to understand the solution that shows the relationship between a Protein and a Molecule. I can do a class diagram in UML showing that relationship (the problem domain), and my OO solution can therefore mimic it in a lot of ways. There's traceability from the problem to the solution. I'm not seeing how this is done in FP at a higher level (before functions).
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
Business concerns (from the customer) aren't expressed very often in higher-order functions. But a customer can write a one-line user story and provide you with business rules (or you can get them out of the customer). I'm interested in the (top-down?) domain modeling (from those artefacts) that allows us to arrive at abstractions of the problem that map to first-class functions, etc. Can you cite some references? Can you use a concrete example of a domain, the abstractions, etc.?
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
if you know what input a function takes and what output it produces, why should it matter which data structure it belongs too? That sounds a lot like cohesion, which for any modular system is important. I'd argue that not knowing where to find a function would make it harder to understand a solution, which is due to higher representational gap. Lots of OO systems have this problem, but it's because of bad design (low cohesion). Again, the namespace issue is out of my expertise in FP, so maybe it's not as bad as it sounds.
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
I like your answer because it has concrete examples, but the abstractions are data structures, which have been around since C. What about writing software for a business domain, such as microbiology or a judicial system? How does a FP solution look when you need to model business entities in the solution, e.g., proteins and molecules, or trials and defendants?
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
@AndresF. perhaps it's all about modularity and organization, but in OO designs it's common to have a domain layer, where objects in the solution map to objects int the problem. Not all of an OO design is low-level details. I'm claiming the representational gap is lower when solution abstractions map to problem abstractions. I think I'm getting the gist that the naturally functional aspects of a problem domain, which relate to data flow, map easily to FP. So again, I'm curious about the problem modeling step in FP that sets up the natural low-gap mapping.
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
Because of encapsulation and data hiding, which are not OO principles per se, I don't entirely agree with OO being data structures + algorithms (that's the internal view only). The beauty of any good abstraction is that there's some service it provides to solve part of the problem, without one needing to understand too many of the details. I think you're talking encapsulation when you separate functions and data in FP, but I'm too green to know for sure. Also, I edited my question to refer to tracing from the solution back to the problem (to clarify the meaning of representational gap).
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
@Giorgio To me, traversing directory structures or filtering files is a low-level problem (classical computer science which is closer to math than the rest of software engineering), at least within a system that has to provide online ordering and delivery of goods. Of course, OO systems have the same lower-level problems, and I'm not saying they do a better job at solving it. But a class called FileUtilities might make more sense to me what its role is (I'd understand its purpose in the scheme of the solution space and problem space).
Jan
26
comment Does functional programming increase the 'representational gap' between problems and solutions?
I edited my question to speak about traceability from solution to problem as being a benefit of decreased representational gap. Can you explain in FP how its abstractions are easily traced back to the problem space?