c# - How can I maintain a few mostly identical software products but based on the same codebase? -
please bear me , let me explain. work vehicle insurance company , trying develop online portal our customers can purchase insurance policies. let's offer 3 insurance products car insurance (ci), motorcycle insurance (mi) , truck insurance (ti). , shall 90% of these products similar in terms of how implement them differ in remaining 10%.
let me use c# example demonstrate (below code rough idea demonstrate problem not real code).
public class carinsurancepolicy { //common properties among 3 insurance products public decimal madeyear {get;set} public decimal purcahseprice {get;set} //specific particular product public bool hascentrallocking {get;set} public datetime specialdatetodowithcar {get;set} } public class motorcycleinsurancepolicy { //common properties among 3 insurance products public decimal madeyear {get;set} public decimal purcahseprice {get;set} //specific particular product public int enginestroke {get;set} public datetime specialdatetodowithmotorcycle {get;set} } public class truckinsurancepolicy { //common properties among 3 insurance products public decimal madeyear {get;set} public decimal purcahseprice {get;set} //specific particular product public decimal loadcapacityintons {get;set} public datetime specialdatetodowithtruck {get;set} }
as can see each of policy class have properties same quite different each type. , comes database part.
i don't know if should this
create table baseinsurancepolicy ( //all common columns ) create table carinsurancepolicy ( //specific type of product ) create table motorcycleinsurancepolicy ( //specific type of product ) create table truckinsurancepolicy ( //specific type of product )
or should this
create table giantinsurancepolicytable ( //all columns , nullable )
and comes workflow part
we have few basic common steps rate type of product. take account of made year, km travelled etc form basic rating , depending on specific type of product , have special way calculate premium.
public class ratingengingforcar { //can common step public decimal getpremium() {} //specific car private void applya() {} private void applyc() {} } public class ratingengingformotorcycle { //can common step public decimal getpremium() {} //specific motorcycle private void applye() {} private void applyf() {} } public class ratingengingfortruck { //can common step public decimal getpremium() {} //specific motorcycle private void applyx() {} private void applyz() {} }
then have workflows again 90% similar 10% differ quite significantly. again it'll same generating insurance policy (the actual policy doc) , invoices.
so don't know if whether should come kind of generic yet flexible way form base classes , start inheriting , modifying specific behaviour each product. or should copy past 1st product , modify 2,3,4,5 products?
in terms of ui, trying componentize our javascript in general long html structure same , id/name/class functionality provided *automatically including , initiating js. trouble need duplicate html everywhere every products.
i don't know if i've explained problem clear enough high level. if not update / clarify based on comments. thank much.
on code side, problem object orientation there solve. put common functionality in base class , derive more specialised classes that.
you can similar thing in database. example, have policy table column each of common properties plus id. can have specialist tables containing other fields (e.g. 1 table car insurance) column that's foreign key reference base table.
you add view database presents these if 1 giant table, haven't lost structuring nicely.
Comments
Post a Comment