anna_gari_maata Posted 14 hours ago Report Share Posted 14 hours ago 14 hours ago, dasari4kntr said: there are object initializations using NEW keyword…in the constructor..how do you deal with them..? Expand powermockito.whennew() can be used to assign a mock SqlDatabase object. Then use reflection to access the database mock. Then verify that database is calling save. Generally the whennew() should work within method I guess this works with in constructor too. .. I may give this answer on the fly in an interview but don't know the exact trueness Quote Link to comment Share on other sites More sharing options...
Abhagyudu Posted 14 hours ago Report Share Posted 14 hours ago 14 hours ago, dasari4kntr said: there are object initializations using NEW keyword…in the constructor..how do you deal with them..? Expand Dependency injection kada bro..should not be using new in there..constructor injection cheyachu kada.. enka test ki mock pass cheyachu ctor lo 1 Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted 14 hours ago Author Report Share Posted 14 hours ago 14 hours ago, anna_gari_maata said: powermockito.whennew() can be used to assign a mock SqlDatabase object. Then use reflection to access the database mock. Then verify that database is calling save. Generally the whennew() should work within method I guess this works with in constructor too. .. I may give this answer on the fly in an interview but don't know the exact trueness Expand yes...you need powermockito for that...but still your test is fragile...and your tests will be slow... the same class...if i change using last SOLID principle .. (dependency inverrsion)....this is how it looks...and its easy to write better unit test.. // Refactor to use dependency injection class OrderService { private final Database database; private final Logger logger; public OrderService(Database database, Logger logger) { this.database = database; this.logger = logger; } // ... rest unchanged ... } 1 Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted 14 hours ago Author Report Share Posted 14 hours ago 14 hours ago, Abhagyudu said: Dependency injection kada bro..should not be using new in there..constructor injection cheyachu kada.. enka test ki mock pass cheyachu ctor lo Expand yes.....exactly.. thats why i gave poorely written code...as example...to prove the importance of SOLID principles... Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted 14 hours ago Author Report Share Posted 14 hours ago 14 hours ago, anna_gari_maata said: Dependency injection far more easier than SOLID. ee kaalam lo Spring vacchaka kooda DI questions ante driver role ki car mechanic interview chesinattu untadi... SOLID daka kooda evadu rayatle because most of the legacy code founders rastaru only new project aithe tappa. IMO ippudu vacche developers ki end-to-end and system level knowledge is more important than foundations and principles. If we want to hire a butler they don't need to know how the building pillars are made But again it also depends on the role they're hiring Expand dependency inversion is SOLID principle…Dependency Injection…is the technique to implement dependency inversion… for example…you moved to a nee project like from java to python or something else…అక్కడ నీకు.. springboot antha easy గా ఉండవు…ready గా… i am old developer…i seen bad legacy code and using SOLID how we refactored it…thats why i always give importance to this concept… Quote Link to comment Share on other sites More sharing options...
Popular Post anna_gari_maata Posted 13 hours ago Popular Post Report Share Posted 13 hours ago 14 hours ago, dasari4kntr said: dependency inversion is SOLID principle…Dependency Injection…is the technique to implement dependency inversion… for example…you moved to a nee project like from java to python or something else…అక్కడ నీకు.. springboot antha easy గా ఉండవు…ready గా… i am old developer…i seen bad legacy code and using SOLID how we refactored it…thats why i always give importance to this concept… Expand I genuinely agree SOLID principles are very important avi vacchina vallu expert designers.. avaleela ga design patterns rayatam ante mazak kadu. daniki chala years practice kavali, clean code lanti books chadavali ee kaalam lo standards kante delivery is most important aipoyindi, emaina ante microservices unnayi kada antunnaru ...nenu ippudu chustunna interviews lo anni Tools e adugutunnaru. Employee entha nerchukodaniki ready anedi chudatledu, adi konchem wrong approach but generation ala undi 3 Quote Link to comment Share on other sites More sharing options...
Pavanonline Posted 12 hours ago Report Share Posted 12 hours ago 18 hours ago, Spartan said: frankly....interviews ki tappa...real world daily work lo does anyone even care about these anna.. SOLID, ACID... etc vatillo unna concepts over the period experience to ostai....but desining or coding appudu I havent seen anyone bring this up and adhere to them.. unless someone wants to play Devils Advocate during the session.... @Konebhar6 @dasari4kntr @csrcsr Expand Microservices made lot of oops design obsolete. No one writes tons of classes anyway. Quote Link to comment Share on other sites More sharing options...
Mr Mirchi Posted 11 hours ago Report Share Posted 11 hours ago 18 hours ago, dasari4kntr said: రెండు interviews..లో ఇద్దరిని అడిగితే …ఇద్దరూ నీళ్ళు నమిలారు… Expand Neellu pettakapothe beer pettochuga kanisam Quote Link to comment Share on other sites More sharing options...
Mr Mirchi Posted 11 hours ago Report Share Posted 11 hours ago 17 hours ago, dasari4kntr said: sare.. @Spartan @Mr Mirchi...ee code ki unit test ela raastro.. cheppandi.... class OrderService { private final SqlDatabase database; private final FileLogger logger; public OrderService() { this.database = new SqlDatabase(); this.logger = new FileLogger(); } public void processOrder(Order order) { try { database.save(order); logger.log("Order processed: " + order.getId()); } catch (Exception e) { logger.log("Error processing order: " + e.getMessage()); } } } Expand Db lo kuda interview cheyalaaa… Adhyaksha idhi nyayamrnaaa Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted 11 hours ago Author Report Share Posted 11 hours ago 11 hours ago, Mr Mirchi said: Neellu pettakapothe beer pettochuga kanisam Expand lol…can you give your contact…next time..if they can’t answer question…i will call you to serve beer… Quote Link to comment Share on other sites More sharing options...
halwafan Posted 9 hours ago Report Share Posted 9 hours ago antha kashtamem kadu mari.. Quote Link to comment Share on other sites More sharing options...
hunkyfunky3 Posted 8 hours ago Report Share Posted 8 hours ago 14 hours ago, anna_gari_maata said: Dependency injection far more easier than SOLID. ee kaalam lo Spring vacchaka kooda DI questions ante driver role ki car mechanic interview chesinattu untadi... SOLID daka kooda evadu rayatle because most of the legacy code founders rastaru only new project aithe tappa. IMO ippudu vacche developers ki end-to-end and system level knowledge is more important than foundations and principles. If we want to hire a butler they don't need to know how the building pillars are made But again it also depends on the role they're hiring Expand With experience, people automatically adapt SOLID principles without even knowing... These are not like inventions, someone put together the best practices based on lessons learned over time. Just like how OOP evolved from lessons learned from functional programming. Yes, now a days 90% coding is cookie cutter..use libraries and implement business logic. Unless some one is writing core reusable libraries , you don't need expert software engineering skills. Quote Link to comment Share on other sites More sharing options...
AnotherTeluguBidda Posted 4 hours ago Report Share Posted 4 hours ago “Dependency Injection” is a 25-dollar term for a 5-cent concept. That’s not to say that it’s a bad term... and it’s a good tool. But the top articles on Google focus on bells and whistles at the expense of the basic concept. I figured I should say something, well, simpler. The Really Short Version Dependency injection means giving an object its instance variables. Really. That’s it. https://stackoverflow.com/questions/130794/what-is-dependency-injection#:~:text="Dependency Injection" is a 25,an object its instance variables. DI anedi okkate solid lo use chestham emo…..its a simple concept with a complex name. migathavi we dont usually care for example Liskov principle is taken care by compliers. Its good to know all these concepts but they are simple but not as important as tools. 1 Quote Link to comment Share on other sites More sharing options...
hunkyfunky3 Posted 3 hours ago Report Share Posted 3 hours ago 12 hours ago, Pavanonline said: Microservices made lot of oops design obsolete. No one writes tons of classes anyway. Expand You mean MS frameworks like spring boot etc ? That's what I was saying- not many write reusable, library kind of code these days. There's a section of people arguing that over engineering in the name of reusability etc doesn't hold practical value given how fast everything is changing, especially for start-ups and low- volume intranet applications. For start-ups, once they see traction and userbase they rewrite from scratch as v2. V1 is always with off the shelf, easy to prototype frameworks which allows you to do 90% with 10% of effort. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.