Tutorial :Advice/tools for working on a large existing rails application? [closed]



Question:

I recently joined a new company with a large existing codebase. Most of my experience has been in developing small-medium sized apps which I was involved with since the beginning.

Does anyone have any useful tools or advice on how to begin working on a large app?

Do I start at the models and move to controllers? Are there scripts to visually map out model relationships? Should I jump in, start working on it and learn the apps structure as I go?


Solution:1

Railroad should help you understand the big picture. It generates diagrams for your models and controllers.


Solution:2

I found unit tests to be the most efficient, effective and powerful tool. So, before making any change, make sure your application has a minimum LOC so that you won't break any existing feature working on.

You should care about unit tests (of course I'm talking about unit/functional/integrational tests) because:

  • they ensure you won't break any existing feature
  • they describe the code so that you won't need tons of comments everywhere to understand why that code fragment acts in that way
  • having test you'll spent less time debugging and more time coding

When you have tests, you can start refactoring your app. Here's a list of some tools I usually work with:

You might want to view some of the wonderful Gregg's videos about Scaling Rails to get more powerful tools.

Also, don't forget to immediately start tracking how your application is performing and whether it is raising exceptions. You can use one of the following tools

If you need to fix some bug, don't forget to reproduce the issue with a test first, then fix the bug.


Solution:3

Not specific on Rails, but I would start reading the requirements and architecture documentation. After that get familiar with the domain by sketching the models and their relationship on a big sheet of paper.

Then move on to the controllers (maybe look at the routes first).

The views should not contain that much information, I guess you can pretty much skip them.

If you still need to know more, the log of the versioning system (given they use one) is also a good place to get to know how the project evolved.


Solution:4

When I've been in this situation, I try one of three things:

  1. Read all the code top to bottom. This lets you see what code is working, and you can report progress easily (I read through all the view code this week). This means you spend time on things that may not be helpful (unused code) but you get a taste of everything that is there. This is very boring.

  2. Start at the beginning and go to the end. From the login page or splash screen, start looking at that code, then the next page, then the next page. Look at the view, controller, and database code. This takes some time, but it gives you the context for why you need that code or database table. And it allows you do see most often the ones that get used in the most places. This is more interesting.

  3. Start fixing bugs. This has the benefit of showing progress on your new project (happy boss) taking work from other people (happy co-workers) and learning at the same time (happy developer). It provides the context of number 2, and you can skip rarely used code from number 1. This is the most interesting way for me.

Also, keep track of what you've learned. Get a cheap spiral-bound notebook and write down an outline of what you've learned. Imagine yourself giving a talk on the code you're learning about or bug you're fixing. Take enough notes to give that talk, and spice it up with a factoid or two to make it interesting. I give my notebooks dignity and purpose by calling them "Engineering Notebooks", put a title on the front (my name, company, date), and bringing them to every meeting. It looks very professional compared to the guys who don't show up with paper to take notes. For this, don't use a wiki. It can't be relied upon, and I spend a week playing with the wiki instead of learning.

As mentioned above, being the new guy is a good chance to do the things nobody ever got around to like unit tests, documenting processes, or automating running tests. Document the process to set up a new box and get all the software installed to be productive. Take an old box under someone's desk and put a continuous integration install on it, and have it email you when the tests fail. You can forward that email whenever someone else checks in code that breaks the tests. Start writing tests to figure out how things work together, esp. if there aren't any/very many tests.

Try to ask lots of questions in one-on-one situations. This shows you're engaged and learning, and it helps you find the experts in the different parts of the app. On a big project you may need to go to one person for one topic and a different person for other topics. It also helps identify who thinks they know more than they really do or who talks more than you really need.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »