Reflections #Rails, Quality Code

Today we learnt about what constitutes Quality Code:

  • understandable
  • readable
  • tested
  • working
  • clear
  • changeable
  • discoverability
  • documented

We also learnt about rails model associations, how a join table helps join two tables/models’ data for a many-to-many relationship. In teams of two, we drew a diagram called an entity relationship diagram and also used Trello (an online kan ban board) to plot our user stories/app features. We will be working on a twitter app for the next 2-3 weeks.

One of our assignments was to do a kata at Code Wars – Sum with Highest and Lowest .

I tried it and although i passed the tests, i couldn’t pass the null/empty? test. I was annoyed because I just couldn’t figure out what was wrong when i clearly wrote it correctly (if .null? or .empty?) but then in a fit of what-the-heck, I took out the .empty? method, and rerun the tests again, and this time, the code passed. I guessed the question was worded wrongly, It should just be null, not empty, since null != empty.

So lesson here – just write enough to pass the test. And sometimes the questions are wrong. And i nearly gave up actually, I thought there’s no way to pass even if you got the code correct, but then yeah, I guess I got to keep trying.

Advertisements

Reflections 

This week, we learnt to do a forum. We were split into teams of two to work on a forum together, using the kanban method. I think it’s a better method than scrum because it communicates clearly what’s in progress, what’s done, and what needs to be done. I don’t really like scrum because the daily meetings and sprints remind me of my time in an advertising firm and at the tv company. 

At the ad firm, we had daily meetings to talk abt the work, but it didn’t help if the problem wasn’t a lack of communication. The problem was poor sales. And the tv company, the problem was the workload/project was too much for an inexperienced team to handle and the main decision maker or client wasn’t regularly involved in the work progress. These led to tight crunches/many late nights as immovable deadlines loom and staff turnover was high. 

Anyway, we also learnt paired programming – how you work as a pair over a single computer, the driver verbalising his intentions and what he’s doing as he types his code and the observer checks and serves to improve the code through questions and suggestions. 

I want to improve my communication and my understanding of the rails and ruby code and architecture/system. 

Reflections: Model View Controller, Chatbots

Hi, it’s another week (week 3) down at Alpha Camp. This week, we learnt how to do an online photo album using Ruby on Rails, where the user can upload photos to the model(database).

I find this module a bit tough to understand because it introduces quite a bit of technical terms, you may call it jargon; it’s quite abstract and there’s a heap of folders and files generated. But I’m slowly going through it to understand what each component does.

I think what’s interesting is how Rails came to be. One guy who had lots of experience in designing/creating websites and databases saw how messy and repetitive it was, decided to come up with a framework (or library), and a way of defining the structure so that it’s not only faster to develop and get a website running, there’s also a common base for different developers to build on. So whenever you open up a rails site, even if it’s built by someone else, the folders still have familiar names which store familiar components, and you know which is which.

On another note, I’ve been thinking about what to do for our project. One idea I’m interested in is a chatbot. Sort of like Bus Uncle. When it first came out, I was quite blown away. Even though some of the responses were repeated, and even though the app wasn’t particularly quick in giving you the information you want (what bus coming at what time) and other apps can give you more than one bus’s info, I still used Bus Uncle more as it felt like I was engaging with a person. Even though I clearly know it’s a robot. But you know how people even talk to soft toys sometimes, we have a way of personifying objects. There’s an illusion or suspension of disbelief.

I think it’s amazing how far AI has developed in the recent one or two years. It’s almost by leaps and bounds. There’s AlphaGO playing GO against instances of itself and leveling up (sort of like Naruto who cloned himself so that he could get 2X or 100X results from training within a short time) and there’s computers playing atari games and learning from a blank slate through trial and error how to beat the game. Machine learning? I read that there’s also computers reading thousands of scripts so that they can come up with more interesting dialogue. That’s awesome. Although I do fear if computers are able to take over scriptwriting jobs one day.

Anyway, I think people have such busy lifestyles nowadays, and especially for older folks who have work/family and seldom meet up with their friends, there’s a gap for a listening ear in their lives. I know there’s facebook and instagram and whatsapp, but sometimes there’s certain things you’re unable to tell your friends or family. So perhaps if there’s someone you can talk to at your convenience (you don’t have to make an appointment like with a friend), it doesn’t matter if it’s a robot, as long as it can tell you a joke or make you smile – at your lowest point, that would be a most welcome relief anyway.

So maybe, if you have a chatbot that can ask you about your day and make you smile, and show that it cares about you (as it remembers your previous responses and references them), then when you give your answers and reflect on your day, you’re able to think things through and come out feeling more positive or lighter, that would be nice. It’s not a huge improvement, but it oils your day-to-day life.

Ruby on rails MVC

Yesterday we learnt about the model view controller architecture of ruby on rails, how you can use scaffolding or the manual method to set up models (databases), controllers (which processes user input and controls what the user sees) and the view (output on browser). 

That’s my understanding, correct me if I’m wrong. 

So we learnt more in depth about some model commands, how u can send a request to the database and get like how many women and men play sports, from your database. There’s still more to learn like how to switch databases, etc. 

I’m curious what other things can we do with a rails server besides getting database info. Can we send spam, etc? Will Google it. 

Reflections week 2 

Last week, we learnt about bootstrap and flexbox for manipulating html and css. We were supposed to display our work on the projector but my mac couldn’t connect, and I borrowed a classmate’s laptop. It was then that I discovered that my Web page made with bootstrap looks different in his browser. So I guess that’s a lesson learnt, to test yr page in different browsers. Not just chrome. 

What else did I learnt… Ah i almost burnt myself out on the public holiday and the day after. Because I wanted to finish the javascript jquery assignment. I learnt that the clone method needs boolean arguments in order to clone deep data. 

And the day after that during class, when I tried to sort the user rows by coding jquery, I think i spent upwards of 4 hours on it. Not efficient. I think i need to rethink my working and learning style. Perhaps try to get solutions step by step, testing and trying a basic code that’s proven to work before trying to jazz it up. 

And also, don’t reinvent the wheel. If there’s a solution, use it. Don’t be too stubborn and try to code yr own way in. I mean, it’s admirable to try, but also be wise to know when to detour. So that I can cover more ground on other subjects. 

What else? I tried working on the when’s the best time to buy/sell stocks exercise, and I learnt that Ruby and other programming languages have a floating point error when u do even simple math like 0.1 + 0.2. Then u need to round it or find a method online to solve this. For ruby, it’s something like the BigDecimal method. 

Reflections #2 HTML, CSS, Ruby

Today’s the 2nd day in school, although it’s actually the 2nd week already. But because I was away in HK for a holiday, I missed 3 days of lessons. I made it back on Saturday afternoon, and spent the weekend working on the Ruby coding exercises. It was challenging but satisfying in a way.

Objective – What did you do today?
Today, I learnt about HTML, CSS and we cloned the Google homepage. We also learnt some shortcuts to solving some of the exercises.

Reflective – How did you feel today?
I felt a bit bored today during the html, css class because styling CSS is very tedious, sometimes the layout doesn’t go the way you want and you have to try different ways to find out what’s the problem. Even though the Google homepage looks simple, it’s actually quite hard to style one that looks identical.

Interpretive – What did you learn today? (not a lecture note)
Just thinking about the coding exercises I did over the weekend, I think there was an aha! moment when I was doing the coding for checking Ugly Numbers. If it’s divisible by 2,3 and/or 5 only, then it’s an ugly number.

When I started on the question, I used some If/Elsif conditionals and loops, and it was confusing. Then I took a break and started again, and this time i just put 3 “While” code blocks to loop the divisions. No If/Else at all, and surprisingly, it works.

Because if the number (value held in variable) divides by 2 until it cannot divide by 2, it will naturally move down the stack to next “While x % 3” statement which asks implicitly whether it can divide by 3 and proceeds to divide it by 3 until it cannot be divided by 3, and let it move to 5.

Less is more.

Reflection – Questions and problems
I have problem writing a code to solve the Towers of Hanoi recursion problem. Although i understand the solution and can solve it by hand, but writing the actual code is problematic. I think I will need to continue studying Ruby methods, etc, and attempt again next time. (I spent about 2 hours at home trying to google the answer and see other people’s Ruby code, but none seem to work.)

Decisional – What are you going to do tmr?
Tmr I will get some breakfast before class starts. We will be working on static pages.
I will also continue the online Ruby lessons.

Reflections #1

Today was the first day at school. Here’s my reflections.

Objective – What did you do today?
Today I learnt about the Montessori method of education, startups, computational thinking, and we also did some exercises on solving tic-tac-toe, the knight’s tour, binary search (guessing number).

Reflective – How did you feel today?
I feel a mix of emotions. There’s a sense of achievement and challenge in tackling the computational thinking exercises, a sense of wonder at how much there is to be learnt, I’m looking forward to the lessons and hoping I can excel. Also a little worried about whether I can get and maintain a career in this line, because this industry/field is new to me, I don’t know what’s the workload, etc. But I guess I’ll take it one step at a time and learn first. I’m glad that I had lunch with some of my coursemates, we could learn from each other and draw on our work experiences.

Interpretive – What did you learn today? (not a lecture note)
I learn that it’s important to choose the right/good market for your startup or product, because you will be spending some time searching/designing a scalable business model. I don’t think I want to start a startup, I might work for one though. What makes a good market – a large one with complacent incumbents or a small/niche one where you are the leader. Also about computational thinking – it can be used to solve problems, by breaking in down into small chunks, recognising patterns, generalising the problem/solution and coming up with a algorithm/step by step way of tackling the problem.

Reflection – Questions and problems
While chatting with my course mates, they told me about companies testing candidates about BigO notation – i think that’s quite critical knowledge, and the school will be teaching it this week, so I think I have to read it up on my own and to ask my course mates about what I missed, next week.

Decisional – What are you going to do tmr?
I am going away on a holiday and will be back on Saturday. I will try to catch up on my studies on Sat and Sun.