TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Refactoring Code to Enterprise Level

5 pointsby p3rryover 4 years ago
I have been writing code since past 10 years, mostly for small companies which have seen medium level of traffic (50-500 concurrently active user). Last year I moved to a startup where I had to scale code to 5000-10000 concurrent users which has been done nicely so far! Now I have to refactor one of its core functionality to enterprise level software. In short it would be a logistic division of my company and whose end users would be 3-4 tier city users of India who aren’t really so tech Savy ( basically it means exceptions catching and validations should be full proof). Last written code has been working good so far but I am not happy with the ‘if else’ way code has been written! Any suggestions on how to architect a logistic company or how to refactor code that with assumptions it would fail and recover automatically or atleast points developer/data team that some thing wrong has happened (as there are 2-3 dbs which have to kept in sync, thanks to micro services :/) In short I have never written enterprise grade application ! Any suggestions/advise would be highly appreciated.

3 comments

avl999over 4 years ago
This is an incredibly broad question and touches on many aspects of software engineering, devops and operations. For operations, I would recommend having the team read the google SRE book <a href="https:&#x2F;&#x2F;sre.google&#x2F;workbook&#x2F;table-of-contents&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sre.google&#x2F;workbook&#x2F;table-of-contents&#x2F;</a> it has everything one would need to setup a modern operations infrastructure and associated best practices. <a href="https:&#x2F;&#x2F;sre.google&#x2F;workbook&#x2F;table-of-contents&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sre.google&#x2F;workbook&#x2F;table-of-contents&#x2F;</a><p>Sounds like you are unhappy with the quality of code and error handling. Seems like it was written by junior devs? I would recommend having the team read the usually recommended books if they haven&#x27;t. At the bare minimun:<p>* Refactoring by Fowler<p>* Clean Code by Robert Martin<p>If you are using an OO language:<p>* Practical Object-Oriented Design in Ruby<p>The book has &quot;in Ruby&quot; in the title but it&#x27;s a general purpose book on what make OO design &quot;good&quot;<p>Then follow it up with<p>* Patterns of Enterprise Architecture<p>* Clean Architecture<p>These books are not perfect or the be all end all, there are parts of them that might be slightly dated but they get you to a large chunk of the way to the promised land.<p>Lastly, if the application is working, the users are happy, there is no bug infestation and you are not having issues with releasing new features, don&#x27;t feel the pressure to immediately &quot;fix&quot; the code.
tarun_anandover 4 years ago
The best place to start is to read open source code. Start with small but popular repository on GitHub.
评论 #25715278 未加载
Jugurthaover 4 years ago
Here are the thing you can set up in a day or two. These are things you can do right now that will give you room to breathe so you can start to think more broadly, but most importantly, <i>they don&#x27;t require change in code</i>:<p>Take a look at Sentry[0]. It will catch exceptions, group them by type, count them, display them with the stack trace, and more. It has integrations with Slack, GitLab&#x2F;GitHub, etc. It makes creating issues and alerting you easier. You won&#x27;t have to dig into dozens of log files and miss exceptions that happened a few hours ago but are completely drowned by log messages.<p>Take a look at Prometheus[1] and Grafana[2]: you can set them up and have the state of your infrastructure in a dashboard (services up or down, how many times they were down, for how long, etc. Latency, CPU, GPU, disk space, RAM, etc). Whatever matters to you, put it there. You can create custom alerts (example: storage 90% full) to give yourself a heads up and act beforehand.<p>Look at whatever you do as a team when there&#x27;s something wrong, figure out all the information you usually need to troubleshoot, and have it all displayed so you can glance at something and know quickly where something is wrong. This is reactive, but it&#x27;s a start and you won&#x27;t waste<p>For development, you can have issue templates for incidents [service shut down and nobody saw it, etc], and bugs to lower the barrier to entry to write good quality incident reports. This way, people know what to write, where to write it, and how to write it. Put a tag in the template, the people in CC, whatever makes your life easier. Summary, impact, recovery, investigation, future prevention.<p>One benefit of that is that when you have these incident reports, patterns will emerge fast. It surfaces the most frequent and the most impactful pretty quickly.<p>Once this is done, it will save you time and effort that you can put into reading more on the subject. Search for &quot;Site Reliability Engineering&quot;, or &quot;SRE&quot;[3]. There are a few books, some more abstract and others more practical[4][5].<p>Take a look at Enterprise Ready[6]. It talks about the most common requirements and features in an enterprise product (SSO, RBAC, etc).<p>- [0]: <a href="https:&#x2F;&#x2F;sentry.io" rel="nofollow">https:&#x2F;&#x2F;sentry.io</a><p>- [1]: <a href="https:&#x2F;&#x2F;prometheus.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;prometheus.io&#x2F;</a><p>- [2]: <a href="https:&#x2F;&#x2F;grafana.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;grafana.com&#x2F;</a><p>- [3]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Site_reliability_engineering" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Site_reliability_engineering</a><p>- [4]: <a href="https:&#x2F;&#x2F;sre.google&#x2F;books&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sre.google&#x2F;books&#x2F;</a><p>- [5]: &quot;Seeking SRE, Conversations about Running Production Systems at Scale&quot;<p>- [6]: <a href="https:&#x2F;&#x2F;www.enterpriseready.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.enterpriseready.io&#x2F;</a>