当前位置:网站首页>The architect started to write a HelloWorld

The architect started to write a HelloWorld

2022-07-05 03:34:00 Resourceful!

Architects don't make tools , I made one today helloworld!

Today we don't talk about technology , Talk about transition design .

We use helloworld For example ! Ordinary programmers write a Java Output hello world Program ! Architects have a look , Look disdainful . Looking for nails everywhere , Your program is too low 了 , Multilingualism is not supported , Friendly extensions are not supported !

Then the architect started to write a hello world!

The architect's thinking is as follows :

main In the function print once ?

Too process oriented , too low 了 . You have to encapsulate a class . It's called Printer,Printer There is a member method , It's called print.

however ! Just one class is too low 了 , What if there are different implementations in the future ? So we have to add an interface .PrinterInterface.

however !interface There is no realization , Default or default . So we have to add an abstract class ,AbstractPrinter Realization PrinterInterface, then Printer Inherit AbstractPrinter.

however ! You have such a set , How to create an instance ? direct new Printer()? too low 了 , That's called implementation dependency . Definitely not , So we need to build a factory class ,PrinterFactory,PrinterFactory use PrinterInterface Return instance , This hides the implementation details .

however !PrinterFactory It is also an implementation class , too low 了 , So there must be PrinterFactoryInterface,AbstractPrinterFactory.

And in PrinterFactory How to write it in it ? direct new Printer() ? too low 了 . Or implementation dependency .

Last , You have to put this pile of things together in code , It's too ugly , Various new Implementation class . too low!

Fortunately, we have an advanced thing , It's called dependency injection ! Write the program object structure into the configuration file . Of course, you can't make your own wheels . To configure Spring Well . So much lib, On the command line or IDE Project management is definitely not enough , You have to have dependency management .Maven ah Gradle Ah, come on .

Last , want print How can I pass something to the program ? Hard encoding ? Command line arguments ? too low! Of course, it has to be written in XML Inside .

Light is a XML Of course, it's not enterprise class , Plus DTD Verify it .

Then it comes to XML The problem of analysis . Directly operate in the code parser Do you ? too low! Of course, write a parser The wrapper class ,interface,abstract class,implementation class,factory class Another set . After all , Can't rely on Implementation , If I change in the future parser What should I do? .

 So the final product is a pile of configuration files , a pile jar,compile Out of the program 200MB.

Architect version helloworld
IDE You have to install it 300 A plug-in , Open the project hard disk and eat it for a long time 2GB Memory , Then a bunch of plug-ins pop up and ask for an upgrade .

oh , Before this happens , I have to draw UML What about the picture? . Three years later, the project was completed , Deploy to the client's server for a run , Break down immediately , All over the place stack trace.

Originally, the client server used JDK 8 And new projects need JDK 11. Then ask the customer if you can't upgrade , The answer is no , Because the enterprise solution made by another enterprise development group only supports JDK 8. Then the customer scolded your architect , You've done so much design that you never thought you might change JDK Do you ?

Inside code review, The architect is still proud to say , Although I don't often write code , But my code is extensible !

 Insert picture description here

Architects talk on paper
After the meeting, a group of people were talking , Architects seem to have written less unit tests ; There's no documentation ; Others say that the architect's single node hello world What to do if I hang up ?

You have to use microservices ,redis,nginx,docker,k8s wait devops ...

Everything has to be arranged , Doing the job of making artillery battles , With the heart of building a nuclear bomb !

原网站

版权声明
本文为[Resourceful!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140731511325.html