I do not understand why pimcore would change the definition of class inheritance.
I want to create a class e.g. product with base information. From this, I want to create a new class e.g. Sneaker that inherits product - so that when i create a sneaker, it will have all properties of sneaker with inherited properties from product.
This doesnt work. It doesnt seem like this is what inheritance means in pimcore. I have read the pimcore documentation, but it doesnt explain clearly either. How would I go about the above need with pimcore 4 using the admin screens?
Thanks ~
Inheritance works only for the objects of the same Object Class. Inheritance in PIM sense means that the data is inherited in nested objects. It doesn't work in the sense of OOP class inheritance.
In short: only one object class should cover all of your products. Use Object bricks, Key value pairs, Classification store, relations, etc. to model all the different product types.
Class inheritances do not exist in pimcore. For example you have a sneaker and you want it to be added to the product category, this is not a piece of functionality that is supported by pimcore. You either place the sneaker product or if your scenario specifies creating the product category later, create a sneaker product with fake category. I am sure this behavior isn't very intuitive to people coming from more traditional OOP programming languages.
If you have any more misunderstandings, take a look.
Related
I'm currently working on a UML class diagram for an application which is supposed to be like 'Duolingo'.
I am struggling on how to model a many to many relationship.
So, I imagine that you have many users which can take many courses (different languages that they wish to learn). For this reason I have decided to create a courseProgress class to model this many to many relationship.
What I was wondering is, do I need to store the userID and courseID in my courseProgress class? I think I'm getting mixed up here with how keys may be used in a database.
See below diagram:
Am I along the right tracks?
Also, I was wondering when exactly you would use private and public fields. Because to me it seems that you would always want all fields to be private and just use getters and setters to always access these fields?
N.B in the above diagram the fields are public as I have not yet changed them to private
In the diagram above, should I have the userID field and courseID field or should I have a user field of type User and course field of type Course?
You are indeed on the right track. The additional class CourseProgress helps you to better represent the many-to-many association between User and Course. An alternative could have been the use of an association class.
The choice between public, protected or private properties depends on your class design and how you want to expose this information in the object model. This is far too broad to be explained here. To simplify, if the properties are data that could be changed by other objects without any consequence, then you could let it public. If however some properties can only be changed according to some rules with pre-conditions, invariants or post-conditions to be guaranteed, you'd better control the change via a method and thus make the property proteted or private.
Whether or not to indicate the identifiers of the associated classes (i.e. courseId, UserId) depend on the purpose of your diagram.
Typically, for a domain model or a design model, you wouldn't add the properties for representing the classes you are associated with. This is an implementation detail of the association. Usually, you'd rather use the association end to indicate how the instance of the related class would be called.
For an implementation model (example for one-to-many or many-to-many), you may want to show this detail to allow an unambiguous mapping with database tables.
I'm modeling an app which will let users look for real estate properties. So it's going to be a website where users will be able to look for rentals and sales on houses, flats, castles, grounds, shops, parkings, offices. According to that, I'm hesitating in the class diagram. Should I generalize all the type of real estate properties, written above, from the class RealEstateProperty or should I just associate to it a class TypeOfRealEstate, knowing that the type "Ground" for example can be as well a real estate property as the ground of a property like a House or a Castle. Also a parking can be a real estate property as well as a parking of a House.
Anyone has an idea of what's the best way to do that ? Thanks in advance.
It depends of what features of different RealEstates your system has to implement. A class's features include attributes, methods and associations.
If all your potential RealEstates have same features, for example ID, type, price, date and responible agent, and you don't need to firther differenciate among them, than the associated type will do the work. Model RealEstateType as an Enum (or even class, if you expect to add new types) and associate it to a single RealEstate class.
If different RealEstates, on the another extreme, need to have different features, you will need to inherit those from the base abstract class. For example, Ground have an attribute "area", while building has "number of floors". Even methods can be different, or associations.
Following your example, you would like to link Ground to House. This is much cleaner in the second version - just an association between Ground and House class. In one-class version, you would have to link the RealEstate with itself and add spacial restrictopns (very "ugly" design).
In summary, try to think about the features of different RealEstates and make your RealEstate hierarchy based on their differences.
You can end up with a single class or several dozens of them. :) Try to keep this hierarchy as simple as possible (less classes), but enough to mark their different features clarly.
So I'm working on an assignment for school, where I am to model (using a domain model) a web shop that delivers complete grocery bags to people's homes. (http://www.linasmatkasse.se). I wish I could be more specific here, but this is all I have unfortunately.
I haven't received any use case, but the scenario would be something like, add bag to cart, create account/add info, pay.
This is what I have so far : http://i.imgur.com/BIljBtj.png?1
Are there any redundancies? (I only have to depict the model of the site, unsure how much to include).
Could/Should I add composition between for instance Customer and Account, Cart and OrderLineItem, Order and Cart?
Pretty uncertain about attributes & multiplicites in general. Any feedback or support here is appreciated.
Payment class? Is it needed? Should it have payment methods included?
Should I model human elements like support?
Should I model more of the delivery
Is association between customer and order needed?
Thanks a bunch! Again...
It should be a class diagram. So, such verbs as "has", "contains", should be shown as aggregation, "supplies", "describes", "makes" should appear on associations arrows only if these names are the names of the attribute in the source(for arrow) class. "owns" should be shown as a dot on the end of association. Also put attribute names really on ends of the associations. You can name the whole associations, but that implies, that the association itself, without the instances of the classes, somehow exists. If you want to write comments, they are to be placed on the notes. But normally that words as "supplies", "describes", "makes", "has", "contains", "owns", appear on the Use case diagram. Make it apart from the class diagram, if you want to think on this logic or discuss it with a client or a sales manager you work with.
Composition
That one between Account and Cart you have made very nicely. Thus you cay, that Cart doesn't exist out of its Account and any account has only one cart. So, the composition with multiplicity 1 to 1 is sensible and bears a lot of important info.
The customer as you made it, is useless. You need only Account.
Till now I don't understand the use of OrderLineItem and ItemList. If the use of some classes is not obvious, it is bad - at least put comments there or think, if you really need them.
Payment - yes, it is necessary. As for payment methods, put them in the specific Enumeration class block, name them there as items and connect Payment to PaymentMethods.
No human elements here! You are deep into the IT model, on the border of coding. You really want to do a use case diagram, don't you?
Delivery? Maybe more enumerations for way of delivery and supplier, ClientAddress that is seen from Account, Order. It is for you to decide if you want to cover this or that scope.
ItemDescription should be connected to Item only
All you associations are navigable in both ways. It is senseless. Choose the navigability.
If a class attribute is an instance of another class, put a dot on that another end of association (end owned by classifier).
Supplier connected to Order? Do you want to cover the theme of trade with suppliers, too? Then there should be more classes on that theme. And it could be another component and another class diagram. Or is there a graphic error?
I am following this example: Using NHibernate with ServiceStack
In the Contacts class library is there way to not have to create another Product class since we already have the Model or is this required? Seems like dependency injection could be used here.
Also could I move the model and mappings into thier own class library outside of the Services project?
How would I return model that had a property that was another model? I.e. Say we had an employee model that was linked to a person model by Id and the person model contained the employee Date Of Birth, I am not seeing how I would return that.
You don't have to create seperate models (or DTOs), however, I think when dealing with different ORMs the custom DTOs will make life easier. You can easily translate the properties with ServiceStack's property translater or something like AutoMapper.
I would create your DTOs in the manner that you want others to consume them. In other words you DTO's don't need to align with the underlying tables. You can combine models and flatten the data into useful DTOs. In your example the Employee class could expose the date of birth and any other person properties.
You can easily keep your DTOs in a separate project. I have done this in projects where I wanted to re-use the DTO classes elsewhere without including the services.
I am trying to get my hands dirty learning DDD (by developing a sample eCommerce site with entities like Order, OrderLines, Product, Categories etc).
From what I could perceive about Aggregate Root concept I thought Order class should be an aggregate root for OrderLine.
Things went fine so far, however I am confused when it define a create order flow from UI.
When I want to add an order line to my order object, how should I get/create an instance of an OrderLine object:
Should I hardcode the new OrderLine() statement in my UI/Service class
Should I define a method with parameters like productID, quantity etc in Order class?
Also, what if I want to remove the hardcoded instantiations from the UI or the Order class using a DI. What would be the best approach for this?
From what I could perceive about
Aggregate Root concept I thought Order
class should be an aggreagrte root for
OrderLine.
Yes, OrderLine's should most likely be under an Order root, since OrderLine's likely make no sense outside of a parent Order.
Should I hardcode the new OrderLine()
statement in my UI/Service class
Probably not, though this is how it happens often and it is made to work. The problem, as I see it, is that object construction often happens in different contexts, and the validation constraints differ depending on that context.
Should I define a method with
parameters like productID,quantity etc
in Order class?
As in:
public OrderLine AddOrderLine(Product product, int Quantity ... )
This is one way to do it. Notice I used a Product class instead of a ProductId. Sometimes one is preferable to the other. I find I use both a lot for various reasons - sometimes I have the ID and there's no good reason to pull the aggregate root, sometimes I need the other root to validate the operation.
Another way I do this is to implement a custom collection for the children.
So I have:
order.OrderLines.Add(product, quantity);
This feels a little more natural or OO, and in particular if an entity root has many child collections it avoids clutter.
order.AddOrderLine(), order.AddXXX(), order.AddYYY(), order.AddZZZ()
versus
order.OrderLines.Add(), order.ZZZs.Add(), order.YYYs.Add()
Also, what if I want to remove the
hardcoded instantiations from the UI
or the Order class using a DI. What
would be the best approach for this?
This would be a textbook case for the Factory pattern. I inject such a Factory into my custom collections to support instantiation in those Add() methods.
You could use an OrderLine Factory to get instances of Orderlines. You would "new up" an OrderLine object in the factory with parameters passed into the factory method and then return the new instance to your Order object. Always try to isolate instantiations and dont do it in the UI. There is a question here that uses this technique.
Here is a great book you will find useful on DDD.