A little about SOLID and the harsh zombie legacy

Cautious optimistic reflections on the place of modern industrial culture, accompanied by software inherited from ancient times. And a little about the interpenetration of SOLID principles.





I work systematically with Delphi 7 (work like that, cho ...). I support and actively refine an application that has its roots in the early to mid-2000s and is written in a ruthless imperative procedural style. Is it possible to survive mentally in such an environment? After all, "the only way to defeat them is not to become one of them," right?





You can actually see something like this here:





procedure TReport13Form.OnButton1Click(Sender: TObject);
begin
	with MainForm.WorkQuery.SQL do
	begin
		Add('Select ...');
		if ... then
			Add(', ...');
		Add('from ...');
		if ... then
			Add('join...');
		... //   -  .
		Add(Format('where id = %d and operDate = %s',
			[id, QuotedStr(DToS(DatePicker1.Date))]));
      
      



... and other similar obscenities.





But rewriting everything from scratch is something from the area of โ€‹โ€‹radical religious fanaticism (as if someone yelped and automatically swung a slipper just after hearing about Delphi 7).





From experience I will say: you can. Yes, as a result, the style uniformity of the source code of the program is violated, but this is far from the worst that can happen. The worst is โ€œto become one of themโ€ (1) .





1) : . ( , ) : , , , git(2). . . . , . 





2) , git - . , CVS (git ) " ".





, . " "? , : " , : !"? , , , , , , . , , SOLID?





, . -- - ( , , - ). VCL, , . , , . . .





, , : https://bitbucket.org/danik-ik/layoutkeeper/





.





:





ILayoutKeeper - , . .





ILayoutProcessor - . , ,





() , , , (Keeper) (Processor).





, .





, .





S. Single responsibility principle

( ) , : , , / .





, . . . . , S.principle .





O. Open-Closed principle

, Closed ( , , ), ? , . , ! . 





. , Delphi , , , , , , , I. , , , (Open) (Closed). , , . ( - ).





L. Liskov substitution principle

, , ( ) : ( ), , , , , " " . () : . , (, ), ( ). 





, ) , ) , .





() , , , , S - - ( - ), , . 





() - , " " TForm, Forms.TForm uses Forms, . ? , , (?). , S L.





I. Interface segregation principle

: . , S. (ILayoutKeeper) "" (ILayoutProcessor), . , -- S , .





D. Dependency inversion principle

. , , , . ini-, ( , , ) MainForm, - . . , , -- . (), ( ). . D S , , - , . , , . "" EhLib , .





"" -- OeStrUtil, -, . (RxStrUtils.ExtractWord, ), . - , . .





, ? , . .





. , . " ", . SOLID- , . S I , D O (, pet- ), L , , , ( , S O).








All Articles