162
votes
Accepted
Why do many software developers violate the open/closed principle?
IMHO JacquesB's answer, though containing a lot of truth, shows a fundamental misunderstanding of the OCP. To be fair, your question already expresses this misunderstanding, too - renaming functions ...
71
votes
Why do many software developers violate the open/closed principle?
Edit: There seem to be some disagreement about what the open-closed principle actually entails. Luckily Bertrand Meyer, who defined the principle, have put his book online, so you can read it yourself ...
52
votes
Ways to explain code when told it doesn't make sense
Personally, I have encountered multiple variants of code-that-is-hard-to-understand, and each needs a different way to cope with:
Simply messy. Formatting is off, variable names are not clear, ...
21
votes
Why do many software developers violate the open/closed principle?
I would call the open/closed principle an ideal. Like all ideals, it gives little consideration to the realities of software development. Also like all ideals, it is impossible to actually attain it ...
21
votes
Ways to explain code when told it doesn't make sense
The original code is extremely obvious, that is a very good thing. It is boring in the best way, there are no suprises there and you can very quickly see what it is doing.
Your code is very abstract ...
14
votes
Ways to explain code when told it doesn't make sense
With out wishing to be rude, if you find that other experienced engineers are regularly struggling to understand your code, then your actual problem is how to make the code simpler, not how to explain ...
13
votes
Why do many software developers violate the open/closed principle?
Doc Brown's answer is closest to accurate, the other answers illustrate misunderstandings of the Open Closed Principle.
To explicitly articulate the misunderstanding, there seems to be a belief that ...
13
votes
Accepted
Ways to explain code when told it doesn't make sense
Siloed
Framework and Infrastructure code is tricky. It is the dark and messy parts of the code base that hit actual walls, and the worst part is that often the solutions are counter-intuitive, as they ...
12
votes
Ways to explain code when told it doesn't make sense
Get people to look at your code sooner.
Every code base I've ever touched conveys a mindset. A way of looking at things. A big part of my job is molding my brain into something that can work with this ...
11
votes
Ways to explain code when told it doesn't make sense
For what its worth, I also find your changed code quite confusing compared to the original code.
The original code is beautifully simple. Apart from the interface declaration it is basically a three-...
7
votes
Accepted
What is the Advantage of React JS over Pure Javascript + PHP?
React competes with Vanilla Javascript, not with server-side functionality¹.
Example scenario
Consider a simple interactive web application consisting of a slider. When we move the slider, we want ...
6
votes
New components that implement an abstract component, vs variants on a single component.
In the clean code book, there is a passage that goes something like:
Data structures makes it easy to add new functions without changing the existing data structures. OO code(using objects), makes ...
6
votes
Why are React keys limited to strings?
Up-to-date as of 2021
They're not, but the React docs encourage the use of strings over any other type. Any data type will "work" (except undefined as @theHutt points out).
This is because ...
6
votes
Ways to explain code when told it doesn't make sense
I believe this is a problem with my code, as I cannot recall the last time some else's code has taken an hour of explanation to understand.
I'm happy to see this conclusion. Most commonly, people ...
5
votes
Accepted
Is undo and redo possible/feasible with two-way data binding (vs uni-directional data flow)?
Typically you implement an undo/redo feature using a command history. Your UI generates commands with execute and unexecute actions, and the underlying model is changed by playing the command's ...
5
votes
Benefits of using a JS Framework
As with any other question to adopt a technology - it depends on the technology. It depends on your requirements. It depends on any future requirements/the roadmap for the product. It somewhat depends ...
5
votes
Accepted
Why are React keys limited to strings?
React writes the key to the HTML and reads it back when parsing the DOM.
Since the HTML attribute is a string, whatever value you give it must be serialised to a string.
If you wanted to use non ...
4
votes
Accepted
How do functional programming advocates use a framework like React or Angular?
In my previous role we were using mostly pure functions in React. Remember that React is a "library for building user interfaces". Often I see React projects where components are very object-oriented ...
4
votes
Accepted
React - When is a backend necessary?
From my understanding, the front end is the UI that the client
interacts with, and the back end is the server itself.
This is essentially correct. The front end commonly refers to the code that is ...
4
votes
What pattern is a function that returns a component?
"when I look up component factory on Google"
This is your problem. "Component" (as well as "pattern") is a extremely generic term, which (even when restricted to the ...
4
votes
What is the Advantage of React JS over Pure Javascript + PHP?
React, Vue, Angular etc provide a MVC style UI framework which HTML + JS doesn't have.
I guess the benefits are that by using the framework you get a whole load of common functionality that you would ...
4
votes
Accepted
Monorepo dilemma: Where do you store your common business logics?
When I understand this correctly, you have two different apps, and all shared code betwen them needs to be located in one of the packages. Currently, all of the shared code can be classified as "...
3
votes
Accepted
When does it make sense to make an individual React component?
Had exactly the same question when I started working on rebuilding a new landing page, using Vue. I have gone through several stages of refactoring all the codes, and the rule of thumb is readability ...
3
votes
Accepted
REST: How to deal with relative resources?
Reading resources online, one can get the idea that the REST API is seen kind of like an adapter to the database.
That's true, you can get that idea. It's not quite right. The REST API could be an ...
3
votes
Why is JSX good, when JSP scriptlets are bad?
In short:
Front-end developers are expected to know scripting and templating
JSX and JSP are both templating languages
JavaScript is a scripting language
Java is not a scripting language
References
Is ...
Community wiki
3
votes
Accepted
How to store blog post in database - React & GraphQL
I typically use markdown for blog posts' main content. This sits alongside the blog post's other columns (title, slug, categories, etc). The perks of using markdown is that it can be considered a ...
3
votes
Accepted
How to manage chaotic code explosion in React application
As a relatively senior guy in my org, I just plainly reject PRs that have insane code structure, like 30k lines in a single file (I bet much of that is copy-paste).
My suggestion would be to talk to ...
3
votes
Ways to explain code when told it doesn't make sense
Two suggestions come to my mind:
Use models/diagrams to represent the different aspects of your solution/implementation. You can use a paper or a dashboard just to simply draw the ideas/concepts and ...
3
votes
Accepted
Anyone have data on impact on UX of shipping profiling build in production to users?
First and foremost, before you deliver anything with telemetry (and performance monitoring uses telemetry) to send the results to your servers, check with your legal team.
Many countries have very ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
reactjs × 130javascript × 41
architecture × 14
react × 14
redux × 12
design-patterns × 11
web-development × 10
design × 8
web-applications × 8
node.js × 7
front-end × 7
state × 6
authentication × 5
angularjs × 5
typescript × 5
react-native × 5
api × 4
component × 4
react-hooks × 4
php × 3
rest × 3
security × 3
functional-programming × 3
clean-code × 3
patterns-and-practices × 3