Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Monday, October 24, 2016

Thoughts on Refactoring Code

http://www.ben-morris.com/wp-content/library/refactoring-vs-rewriting.gif

I'm working on my CareerCoach job research tool, and I'm finding it very tricky to refactor the code.
There are too many moving parts, too many variables.

I'm trying to convert blocks of code into functions, which means that I have to turn variables into global variables, and that gets confusing.

I think I need to map out in more detail what I'm trying to achieve and then work on each component separately.

For now, it's time for a break.

Saturday, October 22, 2016

Thoughts on My First Code Retreat

When I turned up at the annual Melbourne Coderetreat, I was nervous and reticent.  I am not a professional programmer -- yet -- and I had no illusions of keeping pace with people who do this for a living.  Nevertheless, I stuck it out and learned an awful lot.  The organisers Tomasz and Ilya did a fine job of running the event, and I appreciate their encouragement.

Conclusions and Ideas:
  1. Do puzzle programming.
  2. Make code kata a regular practice.
  3. Focus on one language, either Python or Ruby and learn programming concepts thoroughly.
  4. Attend programming meet-ups, preferably for Python or Ruby, and seek out a mentor.
  5. Attend a DevOps meet-up, at least once.
  6. Make code dojos and retreats a priority.
  7. Learn TDD. (Test-driven development)
  8. Familiarise myself with a testing framework.  Using a text editor and the terminal is all well and good when starting out, but using a properly kitted out IDE is essential.
I will return to this post and add more.  Feel free to leave suggestions in the comments.

UPDATE: Some useful comments
  • Choose one that supports multiple languages: python, ruby,
  • Eventually you'll want to learn emacs or vim, buth these can wait
  • Many of these are combinable: 1 + 2 + 3 + 7

Thursday, October 20, 2016

Turning An Array Into A String on PHP

Consider this ugly piece of code:
// Checkbox handling
$field_33_opts = $_POST['field_33'][0]." ,". $_POST['field_33'][1]." ,". $_POST['field_33'][2]." ,". $_POST['field_33'][3]." ,". $_POST['field_33'][4]." ,". $_POST['field_33'][5]." ,". $_POST['field_33'][6]." ,". $_POST['field_33'][7]." ,". $_POST['field_33'][8]." ,". $_POST['field_33'][9]." ,". $_POST['field_33'][10]." ,". $_POST['field_33'][11];
Doesn't this look better?
// Checkbox handling
$field_33_opts = implode(" ," , $_POST['field_33']);

1,050 hours

It took me 13 working days to complete my first 100 "work" pomodoros as a Junior Software Tester at Profectus Group.  Much of ...