yegor256 / quiz Goto Github PK
View Code? Open in Web Editor NEWRefactor the code to make it look more object-oriented and maintainable
Refactor the code to make it look more object-oriented and maintainable
I was too lazy to make some code but here are the things I noticed:
For the refactoring, why not delete the class and use Files.readAllBytes() and Files.write() instead? Given that the code is so bad, the rest of the project might be too and if we are really lucky getContentWithoutUnicode() is not used at all and then we don't even have to build a new class. :-P
Im seeing that some people rename method names and input arguments. Is it OK in the context of this quiz?
By definition, refactoring means that interface does not change. So I'm wondering whether it's something you want your candidates to figure out or you actually expect that the interface will be changed for (maybe) a better one?
These streams are created for single task. final
them to make it clear and safer.
bad practice
//code agains implementations
FileInputStream i = new FileInputStream(file);
better practice
//code agains interfaces
InputStream i = new FileInputStream(file);
bad practice
//using string class for concat
better practice use string builder or Stringbuffer syncronized
for concat operations String class has a Big O linear time complexity because String class create a new String object every concatenation because
String is an inmutable class and with StringBuilder has Big O constant time complexity StringBuilder is a mutable class and also for concat is better
because if you use the append method this will be adding the string and the end of the String Builder so thats why it has a Big O constant time complexity
//Also missing try catch block for IO operations and closing the stream in the finally block
//use syncronized block instead of syncronized method, syncronized methods locks the whole class
//also this should be an interface parse interface and the concrete implementations of diferents kinds of parsers using decorator
design pattern something similar to the JAVA IO decorator
InputStream in = new BufferedInputStream(new FileInputStream("test.txt"));
Or maybe use strategy or template pattern instead if is planning to have more parsers in the future.
There are two obvious SQL injections in there.
Please update the link to http://at.teamed.io/join.html
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.