Friday, September 12, 2014

The 'app' directory in Ruby on Rails

Stemming from my last post, I just wanted to give a quick overview about what exactly Rails generated when you executed the Rails 'new' command

Start clicking around in all the files and see what they all contain. Make sure you familiarize yourself with all these files because every time you work with a Rails project, this is exactly how its going to look like.

Let's first bring our attention to the app folder and all the sub-directories that it contains.

  • app
    • assets
    • controllers
    • helpers
    • mailers
    • models
    • views

In my head( and probably everyone else) this is the meat of the entire Rails project because it controls all the logic that your rails apps will do. It will contain all the models, all the controllers, and all the views that will be shown to the user. Naturally, you will spend most of your time in this folder. Now lets take a closer look at what the app folder contains.

If you have already clicked on the 'assets' folder you will find that it has even more folders. As you can see, there is space for images, javascript files, and some stylesheets!

Here is an example of an almost finished Rails application that contains stylesheets and javascript files for each controller/view that you will eventually generate.

Now we come to the 'controller' folder that has the logic to 'talk' between the models and the views. Let's say that you have an article 'model' that contains all the characteristics of an article (:title, :body, :author). A 'controller' will have an action to 'Read' all the articles from the model(actually from the database since every model contains a table in the database), store it in a variable and give it to the 'view' to display them on the screen(It's a bit more involved, but this is just the start!)

Here is an example of an almost finished Rails application that contains the controllers. Not every model has to have a controller. Also, remember that controllers are usually very lean( don't have too much logic)!

Next we move onto the helpers, which I've only used sparingly, but it is there to put in some logic for the 'view'. In case you ever have very large chunks of ruby code in the view, just know that you can encase that code in a function and place it in here

Now comes mailers! There are a lot of times when a website needs to send emails automatically. Through the mailers we can set exactly that type of functionality. I'll show you how to do it at some later time.

Now here comes the models, which are a little chunky with the logic, but it's okay, everyone still loves models because they are the basis for what we work with in our application. Now the model is pretty cool because you can think about anything in real life and create a model from it. An Article has (:title, :body, :author), a User has(:email, :name, :password, :Profile), a Profile has (:birthday, :fave_color,...). All models have a table in the database and they can have relations to each other!

Here is an example from an almost finished application

Finally, the last folder in the list is the views. It is precisely what you might think it is, which is the folder that contains all the files of html with embedded ruby code that come together to show a user your site!

Here is an example of something you might eventually see in the one of the view sub-folders

That concludes most of the app folder. I will eventually write about the rest of the files that Rails generated just to clear things up. Also, if you find anything confusing or just downright wrong, please notify me in the comments.

Picking the first Ruby on Rails

I have been away for a while, but I just wanted to share some of the things that I learned in the past month and in what I direction life is taking me at the moment.

Last month my friend needed an app made for a club and she asked me for some help. Immediately, I thought this could be the experience that I needed to get myself out there, so I decided I could help her. Earlier in the summer I was learning some Ruby on Rails and I thought I could make a web app to meet her needs. This will be some quick knowledge for those you that are interested in Ruby on Rails!

Since I am developing on a macbook pro I guess my small expertise on the subject would be on the Mac OS X 10.9 (Mavericks). However, the setup should be different on each system, but in theory the actual Ruby on Rails should be the same! (for my later tutorials)

After writing an entire tutorial on installing Rails, I realized there were tons of tutorials that looked far better crafted for installing rails and I didn't want to repeat what the internet had to offer. Although they do help you install rails here, they want a subscription for teaching you Rails.

Well hopefully you have everything installed... Let's start by looking at what gems Rails offers you!

Fire up terminal and let's get into the Desktop:

cd ~/Desktop

Let's create your first Rails app (make something simple like a blog because that's how I'm learning!):

rails new Blog -d mysql

Make sure you add the mysql database, so that Rails can set that up for you without having to worry about it. You can use whatever database that you want!. (Note: You might have to download mysql with homebrew. If you need help on that just comment!)

You should get a lot of output from Rails that looks a bit like this:

My next post will explain a little bit about what Rails generated and see what you can do with it. If you have any questions about anything up to this point feel free to comment below. I'm doing this to document my progress and help others along the way!

Wednesday, August 20, 2014

A Type of Direction

I have been learning a lot of new stuff and I found a periodic table with all the necessary things that most software developers need to learn. This periodic table was the most useful thing that could have found because it gave me some sort of direction to help me along the way to becoming a developer. For those people who like lists, here is the periodic table in a list form. Its going to be a long journey, but I think I can tackle the basics on my own.

  • Basics 
    • Big-O Notation
    • Algorithm Design 
    • Object Oriented Languages 
    • Software Security Basics 
    • Scientific Computing Basics 
    • Parallel Computing
    • Numerical Mathematics
    • Data Structures
    • Functional Languages 
    • Encryption Basics 
    • Database Systems
    • Game Theory 
    • Robotic Basics 
    • Aspect Oriented Programming
    • Declarative Languages 
    • Network Protocols
    • Distributed Computing 
    • State Machines 
    • Parallel Computing
    • Distributed Computing
    • Procedural Languages
    • Web Application Security
    • Machine Learning
    • Artificial Intelligence 
    • Software Development Process
  • Infrastructure 
    • Basics of ITIL
    • DevOps
    • Build Management
    • Monitoring
    • Automated Deployment
    • Test Data Management 
  • Maintenance
    • Re-Engineering
    • Reverse Engineering
    • Program Comprehension
    • Maintenance Planning 
    • IT Change Management 
  • Lean IT
    • Scrum
    • Kanban
    • Agile Methods
    • Agile Planning 
    • Pair Programming
    • Test Driven Development 
    • Definition of Done
    • Continuous Integration
    • Continuous Delivery 
    • User Stories 
    • Backlog Management 
    • Stand-up Meeting
    • Spike Solutions
    • Planning Game 
    • No Overtime
    • Collect Code Ownership
    • Travel Light
    • System Metaphor
  • Design
    • Component Design
    • Database Design
    • Design Patterns
    • Architecture Pattern
    • Large-Scale System Design
    • Design Notations
  • Requirements
    • Requirements Elicitation
    • Requirements Analysis 
    • Atomic Requirements
    • Requirements Attributes
    • Requirement Reviews
    • Traceability Management
    • Management of Requirements Portfolio
  • Implementation
    • Basics Coding Skills
    • Static Code Analysis
    • Code Refactoring
    • Dynamic Code Analysis 
    • Code Peer Reviews
    • Volume Metrics
    • Code Comments
    • Complexity Metrics
    • Code Format Standards
    • Code Coverage
    • Code Reuse
    • Dependency Analysis
  • Testing
    • Unit Testing
    • Defect Root Cause
    • Integration Testing
    • Service Testing
    • Performance Testing
    • Stress Testing 
    • Exploratory Testing
  • Usability 
    • User Interface Design
    • User Acceptance
    • Usability Labs 
  • Tools
    • Code Analysis Tools 
    • Continuous Integration Tools 
    • Requirements Management Tools
    • Integrated Development Environments
    • Test Automation Tools
    • Profiling Tools 
    • Modeling Tools 
    • Version Control Systems
  • Management
    • Risk Analysis 
    • Expectation Management
    • Task Management 
    • Project Management Basics 
    • Estimations
    • Measurement of Activities
    • Project Controlling
  • Other
    • Soft Skills 
    • Presentation Skills 
    • Empathy
    • Creation of Relationships
    • Conflict Management
    • Negotiation Skills 
    • Rhetoric
    • Intercultural Skills
    • Creativity Techniques
    • Marketing Basics
    • Leadership Basics 
    • Good Manners
    • Intrinsic Motivation
    • Physical Fitness
    • Stop Talking 

Completely Lost!

There are perhaps thousands of young developers who are looking for the right way to start their careers and I am one of those lost people. Not just any kind of lost. I feel as if I trying to learn all the knowledge in the universe and the universe continually keeps adding new knowledge at an even faster pace.

I guess I should give you some of my background to give a clue about where I am at with the whole becoming a developer journey. I went throughout my life not knowing how computers really worked. To me it felt like some magical box that turned on that someone could write their mandatory school papers on. It was not until university that I started to learn about all the different languages that eventually tell the computer what to do. Honestly, that "Hello, World!" was pretty exciting to me. Its been a year and half now since my first computer science course and here I am, extremely lost about where to go.

The thing that fascinated me about programming was not the programming itself, but the things you could do with all the code. I started off as a mechanical engineer (I still am, trying to switch into CS)
, but I could not satisfy my creative side of me. I do know how to make parts from scratch in the machine shop using the lathe, the mill, etc, but all the parts are expensive and require a machine shop. With programming all you need is a computer! However, I am stuck in this infinite loop of wanting to create, but having to learn something new to get it done, think that I need to learn everything, getting frustrated and stopping.

This frustration is caused by the fact that I need to get an internship soon and there is a career fair in the fall at my school, which I do not think I have the skills to walk into and land something for the next summer. I also really need some money because college is too expensive at the moment.

This blog will probably document my becoming a developer journey and all the little things I learn along the way. I know my current way of thinking is fairly poor, so I need to change it for the better. This journey will be for life.