We are having a debate at work and cannot find anything in the internet:
Is it a good practice to mock models? And why?
(Just clarifying, models as in per clean architecture definition)
Thanks
Related
I have been working with MVC frameworks (PHP) for a while now, and I believe I understand the notion of layers separation pretty well.
For whoever is not there yet I'm talking about:
M => Model, data layer;
V => View, the UI of the application;
C => Controller, where business logic and incoming requests are processed;
Recently I came across a few projects that extend this concept by using other layers and extending the model one.
These layers use classes such as services, repositories, transformers, value objects, data mappers, etc.
I also understand the essential idea of DDD but, I'd like to know what this type of architecture mentioned above is called, if these additional layers are connected with DDD and/or any design patterns and if you guys can share some resources (blog post, books, videos, etc) where to learn this stuff from whit the other users of this community.
for reference, I found tereško's aswer on this question which is something very similar to what I am looking for.
Many thanks
These layers use classes such as services, repositories, transformers,
value objects, data mappers, etc.
It's hard to ascribe those to any specific architecture. For example Value objects are aka Data Transfer Objects (DTOs), aka Plain Old CLR/Java Objects (POCO/POJO's) are commonly found in .Net / Java based OO solutions.
More fundamentally, as you might already know, logical Layers ('...are merely a way of organizing your code.'*) are a fundamental concept in software architecture, so you'll find them all over the place, and not specific to any one architecture.
See Panos's in-depth answer for 'What's the difference between “Layers” and “Tiers”?'.
share some resources (blog post, books, videos, etc)
In terms of architectures, architectural styles that use layers, and into which the concepts you list would fit:
5-Layer Architecture (one I documented in 2011, which I still use)
Ports & Adaptors aka Hexagonal Architecture There seems to be a lot about Hexagonal architecture around at the moment, of which this post is the best I have seen.
A lot of the key concepts in both of these are actually very similar.
The general ideas behind both of these are very similar. You'll find other architectures out there, I'm sure, but how much they substantively differ is another question.
I'll make this a community wiki so others can add any resources they know of.
I understand that authentication is essentially classifying hundreds or thousands of classes (individuals). Is there an open source classifier that can be used for the task?
I'm not sure about the authentication. But I'll answer anyway.
Weka is popular and I have used it before, however I've never used it for such a large number of classes to be classified, but that doesn't mean it can't be done!
Weka: http://www.cs.waikato.ac.nz/ml/weka/
It has a GUI and a really easy-to-use Java library, if you're hard-coding. I don't know what you're looking for as you haven't really said, but this is what I suggest!
Good luck!
I am beginning in UML and software analyse and i do not understand how UML and diagrams can influence coding and software architecture while we can directly build the code and its data base without diagrams.
I read lot of tutorials abouat the subject but not enough to understand the utility of UML in coding.
I understand everey diagram and its role. That is not my problem but i do not yet understand their roles after the analyse and design phase.
So what is the role of UML in coding phase of a software ?
Thank you.
The comment by #xmojmr already puts it right. UML creates a model (hence the M in UML) of a system. A model reduces information of a system to a level so it is a) manageable and b) complete. Human brains are not computers and you need a means of communication what the system is all about. You can do that as pure code, as paper document and as UML model. A combination of all is not uncommon. As long as you have tiny systems you can live with pur code and tools like Doxygen. But once it starts getting complex you need some handles. UML offers these to end users, architects, testers, developers, managers, etc. Along with UML you will also need a methodology. UML delivers the syntax how to document a system. But you need some structure above to write a nice novel.
UML-based models play an essential role for coding/implementing a software system in model-based (or model-driven) development. The basic idea is that you start making a model of your problem domain (the domain model), then you derive from it a platform-independent design model, which can be transformed into platform-specific implementation models (e.g. for Java- or C#-based platforms) that are finally encoded in the target languages.
The most prominent part of model-based development is the encoding of model classes (forming the model layer in an MVC architecture for apps) based on a data model (a UML class model) that has been derived from an information design model, which was obtained from a domain information model (where all these information/data models are UML class models).
You can find an instructive example of model-based development in my tutorial book Engineering Front-End Web Apps with Plain JavaScript.
This one is in my point of view a duplicate of that other question. It can't be flagged because there is no accepted answer. The related question on meta stackexchange does not provide a clear solution to that situation.
I think my personal answer was relevant and is applicable to the current question.
To be synthetic, Martin Fowler considers current uses of UML. I think he describe the current practices. Perhaps should these evolve ?
Perhaps would the initial question be the right place to discuss ?
At this blog post one can read three reasons to avoid $this->getServiceLocator() inside controllers. I think that those reasons are valid not just into a controller class but in whatever class that implement the ServiceLocatorAwareInterface interface.
Most times is considered an anti pattern get the dependencies injected using the ServiceLocatorAwareInterface? In what cases this pattern could not be considered an anti pattern and why?
Can anybody elaborate on how an alternative solution (presumably using Zend\DI I think) could be? More specifically, how to avoid the use of ServiceLocatorAwareInterface Modules, Controllers and Bussiness/Domain classes. I'm interesting in know about performance issues around Zend\DI and its solutions.
EDIT
Worth define factories for classes with two or three dependencies when the only thing I will get at the end is move the "injector code" (former $this->getServiceLocator()->get($serviceName)) to factories without solving the testing problem at all? Of course that I will want test my factories too? or no?
I think that factories must be reserved to situations where objects build involve complex tasks. Seem to me that when classes have few dependencies and zero logic (beside the dependency resolving) factories solutions is an overkill of this problem. Beside, with this solution I will end with more code to tests (factories) and with more tests (to test factories) while trying avoid less code in tests implementation. Mocking service locator is an easy thing, cos the interface just have two method and the mocking code could be shared between all tests cases.
Pls, rectify me if I'm wrong ;)
Zend\DI could help, but I will be graceful if someone elaborate about the specifics of this kind of solution.
EDIT 2
Few weeks ago this Zend webinar ("An introduction to Domain Driven Design with ZF2") used this anti-pattern (39:05). I'm right now wandering until what point this's really an anti-pattern ;)
And here more info about this issue.
What Fowler have to said about is here
It's actually really easy to solve this problem, inject your dependencies via the constructor. This removes a lot of the magic that will cause problems in larger applications.
So this means you need to create factories instead of using invokable classes.
As seen in the documentation here: http://framework.zend.com/manual/2.2/en/modules/zend.service-manager.intro.html
Last ZF2 version (zendframework/zend-mvc 2.7.0 and +) throws Depracated warnings if you use the ServiceLocatorAwareInterface, and ZF docs (at the time writing this answer) is not clear and still use this interface. ZF 'gurus' don't talk about updating the docs. It's hard to find a concrete exemple if you are not a ZF2 expert (at the time writing this answer).
But fortunately, Rob Allen wrote a post some years ago to explain how to remove the SL dependency and inject it in your controller : https://akrabat.com/injecting-dependencies-into-your-zf2-controllers/ This solve the problem. Hope this will help !
I can't really grasp the concept of how I can add an ontology model in a repository for storing. For example, I've created an ontology model in Protege 4.3. What's the next step? Suppose I want to store this model in a repository, how do I do that? Do we need to create the repository locally? If so, which application can be used for it?
P.S. I've just started learning this software and I'm a slow learner, so please be patient when answering!
The question makes no sense. I don't understand 'repository' in the given context.
As in, why have you mentioned a repository, at all?
A little knowledge is a dangerous thing...
I found your question whilst searching for a repository of .owl models. In particular, I would like to find the UML metamodel, expressed as an OWL ontology, that I can review in Protege.