Week 4, day 6
Finished off a working version of our Twitter clone, Chitter, before mid-day and then spent about half of the day refactoring it.
When it came to refactoring I knew I wanted to comply with Object Oriented best practice so I seperated out the:
- Sinatra GET and POST methods from the server.rb into appropriate files in a new controllers folder.
- Ruby PostgreSQL stuff into their own files in the models folder,
- ERB files into their individual paths.
- Application helper module in its own folder.
This took me most of the day to get right and I had to search for a lot of answers on the web to get it done.
Then I came up against an obstacle in the form of passing around the user session to other parts of the app. It took me until the early evening to go over every line of my code to really understand what was going wrong but I did eventually fix it. This has definitely given me a greater undertanding of the code.
I also got started on some CSS but it's too hideous to show at the moment.
├── app
│ ├── controllers
│ │ ├── application.rb
│ │ ├── peeps.rb
│ │ ├── sessions.rb
│ │ └── users.rb
│ ├── helpers
│ │ └── application.rb
│ ├── models
│ │ ├── peep.rb
│ │ └── user.rb
│ ├── server.rb
│ └── views
│ ├── flash.erb
│ ├── footer.erb
│ ├── header.erb
│ ├── index.erb
│ ├── layout.erb
│ ├── peep.erb
│ ├── sessions
│ │ ├── goodbye.erb
│ │ └── new.erb
│ └── users
│ ├── list.erb
│ └── new.erb