inheritance, basttract classes, design patterns....

M

mrsanna

Guest
Hello, forst of all sorry for my bad english.
I use grails for about 1 year and I a passionate programmer.
I have a problem on defining the design for an application.
I have one or more companies.
Each of these companies have one or more business and each of these business can be a shop, an ecommerce, a vending machine, and so on.
I'he tried to implement in this way:

abstract class Business {
String name
String state
String notes

static mapping = {
tablePerHierarchy false
}
}

class Shop extends Business {
String street
String street_number
String district
String sector
}

class Ecommerce extends Business {
String website
}

class VendingMachine extends Business {
String street
String street_number
}


What do you think about this solution?
Some folks suggested me to use composite pattern instead.
Thank you.
 

dave

Administrator
Staff member
Nothing wrong there that I can see, I utilise the same pattern very often myself.
 
Top