Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - SRP: Why use instance field values instead of parameters? -


i've read srp, easy 123…, , of resonates me except 1 paragraph, in section named "cohesion" (i've claimed before "get" cohesion, talk of parameters vs instance fields gives me pause...):

take class. @ methods. have parameters or using instance fields? if using parameters, remove them. make them instance fields. end methods use 1 of 5 instances? warning of low cohesion exists between method , class.

is removal of parameters merely temporary exercise reveal methods approaching static-ability (low cohesion), idea being return use of parameters when you're finished?

or preference instance fields on parameters actual design technique maintain high cohesion?

have somehow taken quote out of context?

crud real common approach interface based programming. take 2 concrete classes implement crud interface: employee , building.

now imagine how code being parameter based:

employee employeeobj = new employee(); building buildingobj = new building();  string firstname = "bob"; employeeobj.create(firstname); 

what building?

buildingtypes buildingtype = buildingtypes.one; building.create(buildingtype); 

woops...how supposed implement crud interface different parameters? create overloads? more interfaces? 2 params (firstname lastname)?

this ugly fast....because use parameters crud interface have more 1 reason change, decreases design's cohesion.

let's try using our objects/instance based params...

employee empobj = new employee(); empobj.firstname = "bob";  empobj.create();  building buildingobj = new building(); buildingobj.buildingtype = buildingtypes.one;  buildingobj.create(); 

with simple crud , no params 1 can sprinkle in polymorphism:

someobj.create(); 

this leads encapsulated composition, decoupling, srp, etc...


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -