I roughly know how to make a mvc uml class diagram en can find enough info/ examples on the internet. The only thing i cant find info about is if it makes a difference when you have a jacascript controller/model and a c# controller/model.
In general: no.
UML is technology independent. Most models don't assume the technology. MVC can also be applied to different programming languages.
You only need to be aware that there are some concepts that are not handled by particular languages. The only thing that comes to my mind here is multiinheritance. Just use interfaces instead of (eventual) multiinheritance and there'll be no problem.
I can also imagine that some details can be designed in different ways to achieve better performance, but you'd need to know both languages perfectly to be able to make such decisions.
So don't bother about specific language and your diagram will be fine.
Related
I'm currently writing a blog entry that is also about model-2-model transformations. I would like to explain shortly what a model-2-model transformation is in this post. Therefore I would like to come up with a simple example of two models, where the first is transformed to an instance of the second. Both models should be well known to developers, so that I don't need to explain them.
However I couldn't come up with some example models. ATL uses a family and person model in one of their tutorials, but they also require extra explanation as I think.
So do you know an example that I can make use of?
If you want to explain m2m to developers, you can use an M2M-trafo from petri nets to uml activity diagrams. Because activity diagrams are based on petri nets it should not be to complex. I think both models should be known by a developer. Sure, they are not easy, but a developer should know them.
http://en.wikipedia.org/wiki/Petri_net
http://en.wikipedia.org/wiki/Activity_diagram
Sure you should keep as simple as possible. This means you should only describe the transformation for a subset of modeling possibilities. For petri nets I only would use simple states and transitions as subset of the metamodel. For activity diagrams I only would use actions and transitions.
There should already be existing examples of this transformation, so you can also use existing knowledge.
Another thing I want to point out is, that someone how learns M2M-trafo understands what M2M-trafos are used for. Because this case described above can be used in practice.
I chose object relational mapping (ORM) as an example in my blog post. ORM can be viewed as a bidirectional transformation from a relational database model to an object oriented in memory model.
Most (every) developer should know about ORM. But the problem might be that this could cause devs to think about m2m in terms of Hibernate, JPA, etc, which is not the case.
As an example you may consider translation from one language to another. There is an example of translation from UML to OWL.
I am developing my system with helper classes and I see on several sources that say "Helper classes" are not recommended in object orientated programming.
If so, why are they considered bad?
How do they play in with the MVC framework of Codeigniter?
Thanks
The strength and weakness of the helpers is that they don't neatly fit into the MVC framework; they're more like glue than wood or steel framing. They can be convenient to use in several contexts and are well-suited for common, light tasks. If your helpers become more complex and start needing to interact with models and controllers, odds are you've got a questionable design that needs to be more carefully considered. Glue and duct tape may be useful, but you'll be hard-pressed to find a skyscraper made of them.
Is it at all practical to implement an object model in functional style?
One problem that OOP seems to excel at is describing object models.
For instance, an HTML DOM is a complicated, stateful beast which interfaces directly with the UI and requires programmability from dynamic languages. OOP features tend to come in useful in a lot of ways:
Member access constraints make interfacing with untrusted code (e.g. javascript) safe
Accessor functions and properties make binding to the UI much more convenient
Not having to pass around the object model all the time makes methods a lot simpler.
The UI side of the story might be a bit moot if you're projecting the model via MVVM, but you're still constantly wrestling with state internally.
I'm working in F# for this project so I could easily resort to OOP, but I'm curious as to how far I can push it before it becomes impractical. Are there maybe design patterns or anything?
This is a bit philosophical to have a "correct" answer but okay I'll bite.
In my opinion the problem comes because you consider FP and OO to be juxtapose, they are not. FP and imperative programming are juxtaposed, i.e. using expressions versus using statements.
Part of the problem is that OO lacks a clear definition, well in my opinion anyway. To support this I'd point to Alan Kay who said “Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind.”, yet most language we consider OO i.e. java/C# take more after C++ than smalltalk.
What OO C++/java/C# style does give us is a nice way to organize our code into models, create data contains add properties to them etc. Non of this is practically un-functional and can be used nice with functional programming.
As you point out a lot of C++/java/C# tend to be stateful, but they don’t have to be, both java and C# have fundamental types such as their string classes that are immutable. It’s true java and C# don’t make it easy to create immutable class but with a bit of effort you can do it.
Which brings us to where is immutable appropriates? In my designs usually start of by making everything immutable, since this makes getting things correct easier, and if I see this causing performance problems I start adding some mutability on the critical paths. The one place immutability is never going to work is GUI controls, which generally contain far too much state to be immutable. Having said that you can get quite a long way building GUI using a immutable “combinator” approach then is then interpreted by mutable gui controls. This is more or less what the WebSharper guy’s do: http://www.intellifactory.com/products/wsp/Home.aspx
Another great resource for the FP/OO debate is Brain’s “How does functional programming affect the structure of your code?” (which greatly influenced my thinking about FP/OO): http://lorgonblog.wordpress.com/2008/09/22/how-does-functional-programming-affect-the-structure-of-your-code/
Would an activity diagram be the best way to express validation rules for an HTML form, using a whole bunch of decision nodes? I am not convinced that it is, but I can't find a more appropriate one, nor can I find any examples of validation rules models online.
None - no one in their right mind would create a graphical representation of form validation rules. UML is not the same thing as engineering drawings, in spite of the best efforts of its proponents.
You're doing it wrong if the effort required to create the UML diagrams for a system approaches that of actually developing the code. Better to have running code that you can actually unit test. The unit tests are better documentation than UML will ever be.
Don't try to represent everything in UML.
An UML diagram is good idea. Activity diagram can be created with graphical rules (e.g. pink annotation).
It is a good start even before codding.
For any non-trivial rule you´ll need to use a language like OCL to be able to express the rule.
Validation is fired in case of a misuse case so it Can be represented using activity diagrams. Sequence and activity diagrams also help you debug production issues and nail them quickly
I'm looking for patterns that concern coding parts of a GUI. Not as global as MVC, that I'm quite familiar with, but patterns and good ideas and best practices concerning single controls and inputs.
Let say I want to make a control that display some objects that may overlap. Now if I click on an object, I need to find out what to do (Just finding the object I can do in several ways, such as an quad-tree and Z-order, thats not the problem). And also I might hold down a modifier key, or some object is active from the beginning, making the selection or whatever a bit more complicated. Should I have an object instance representing a screen object, handle the user-action when clicked, or a master class. etc.. What kind of patterns or solutions are there for problems like this?
I think to be honest you a better just boning up on your standard design patterns and applying them to the individual problems that you face in developing your UI.
While there are common UI "themes" (such as dealing with modifier keys) the actual implementation may vary widely.
I have O'Reilly's Head First Design Patterns and The Poster, which I have found invaluable!
Shameless Plug : These links are using my associates ID.
Object-Oriented Design and Patterns by Cay Horstmann has a chapter entitled "Patterns and GUI Programming". In that chapter, Horstmann touches on the following patterns:
Observer Layout Managers and the
Strategy Pattern Components,
Containers, and the Composite Pattern
Scroll Bars and the Decorator Pattern
I don't think the that benefit of design patterns come from trying to find a design pattern to fit a problem. You can however use some heuristics to help clean up your design in this quite a bit, like keeping the UI as decoupled as possible from the rest of the objects in your system.
There is a pattern that might help out in this case, the Observer Pattern.
I know you said not as global as MVC, but there are some variations on MVC - specifically HMVC and PAC - which I think can answer questions such as the ones you pose.
Other than that, try to write new code "in the spirit" of existing patterns even if you don't apply them directly.
perhaps you're looking for something like the 'MouseTrap' which I saw in some articles on codeproject (search for UI Platform)?
I also found this series very useful http://codebetter.com/jeremymiller/2007/07/26/the-build-your-own-cab-series-table-of-contents/ where you might have a look at embedded controllers etc.
Micha.
You are looking at a professional application programming. I searched for tips and tricks a long time, without success. Unfortunately you will not find anything useful, it is a complicated topic and only with many years of experience you will be able to understand how to write efficiently an application. For example, almost every program opens a file, extracts information, shows it in different forms, allow processing, saving, ... but nobody explains exactly what the good strategy is and so on. Further, if you are writing a big application, you need to look at some strategies to reduce your compilation time (otherwise you will wait hours at every compilation). Impls idioms in C++ help you for example. And then there is a lot more. For this reason software developers are well paid and there are so many jobs :-)