c# - Correct interface of a business logic class -
in program separated ui business logic; have garage, containing list of vehicle(licenseplate, coniditionofvehicle)
i want allow users of garage receive list of licenseplates @ specific given conditionofvehicle.
what should return type of method? ilist of string (exactly requirement states) vs ilist of vehicle (allowing client see more properties of car, thereby improving extensibility)
are allowed return vehicle? allow user change things might not want him to. (assume client has access "vehicle", using builder receive vehicle, , calls garage.addvehicle(vehicle) add garage)
thanks
there yagni (you arent gonna need it) principle states:
always implement things when need them, never when foresee need them.
if requirement says 'users need list of licenseplates' return users need without trying foresee might need. otherwise wasting time on forecasting, adding possible problems (changing of vehicles user), making code unexpected both users (they expect licenseplates) , maintainers (they don't know new requirement come from), , worst thing - new 'feature' might not used users.
another principle trying violate returning whole vehicle instance kiss (keep simple, stupid):
if have choice between simple solution , complex one, opting complexity stupid.
returning list of strings more simple solution, satisfies requirements. there no need add needless complexity system.
Comments
Post a Comment