refactoringguru / refactoring-examples Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
the last has: speed = bird.getSpeed();
but, to create the bird object shouldn't we again create use the swirch case? like this:
switch (type) {
case EUROPEAN:
Bird bird=new European();
case AFRICAN:
Bird bird=new African()
case NORWEGIAN_BLUE:
Bird bird=new NorwegianBlue()
}
so, what is purpose for this solution actually? or is there something that i missed?
class Gamma
have
private importantValue1
and in method compute int importantValue1
and so on...
should it be better delete fields from class and use local variables in method ?
thx!
See this problem: https://refactoring.guru/consolidate-duplicate-conditional-fragments
The problematic code is:
if (isSpecialDeal()) {
total = price * 0.95;
send();
}
else {
total = price * 0.98;
send();
}
The proposed solution is:
if (isSpecialDeal()) {
total = price * 0.95;
}
else {
total = price * 0.98;
}
send();
yet it still duplicates the logic of calculating the total.
A better solution would be something like this:
total = price * (isSpecialDeal() ? 0.95 : 0.98);
send();
Hey there! I stumbled upon your website and have been learning quite a lot about refactoring and design patterns. Thanks for the free content!
I was just wondering if you guys need C++ examples, or examples in any particular language. I see you have C# examples already; I know the two languages are fairly similar except for some OOP semantics, so I was debating the value of adding C++ to the list as a PR.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.