Que sera, sera, whatever will be, will be, but first I need more coffee.

Year: 2015 (Page 1 of 5)

Winter Solstice

It's only a little thing. We used to go to a friend's house for a Winter Solstice party and one of the ceremonies was to write on a piece of paper things we'd like to get rid of and things we'd like to come in to our lives. Then we'd throw them in a small fire outdoors and make some kind of incantation. Of which I'd forgotten the words.

Those friends have moved away and we have moved away. Those parties are no more. So this year I thought about what I'd like to go and what I'd like to come in: resentment and forgiveness. I need to let go of my resentment that a different friendship was destroyed and that I need to forgive those that destroyed it. The friend who was lost has passed away, so there is no restoring it.

Test Driven Development is driving me nuts

I’m working my way through Test Driven Development With Python and I don’t quite grok it yet. It feels like I’m missing part of the puzzle. Granted I’m only in the early stages of the book, but still. It feels like how the Underpants Gnomes operate:

Step 1: Collect underpants.
Step 2: ???
Step 3: Profit!

As a developer I want to be more rigorous in my development process. Right now I’m a bit of a cowboy coder (no, not in the cyberpunk cowboy hacker sense). In the sense I play it by ear and that my process changes with little formal documentation. My source control is making copies and storing them on my computer or having two setups. I do keep notes but they aren’t in one central repository nor labeled for what project they belong to. Most of my documentation is the email conversation I have with my clients.

The TDD process is

Step 1: Write a test that fails
Step 2: Write shell code that makes the test pass barely
Step 3: Rewrite the code so it actually functions and passes the test.
TDD Global Lifecycle

It seems backwards. You write a test first then write the code that will pass it. The step I’m missing is the requirements. Just because you write it so that it passes, it doesn’t mean the code will actually do what you or the client wants it to do. And then in the back of my mind I’m conflating it with today’s teaching methods in grade school. Kids aren’t being taught to learn. They are being taught to pass the test which means they aren’t really learning anything.

So I guess that is my big fear that I’m not learning anything. Just how to be a better test writer.

Don’t get me wrong. Testing code is essential but you can’t think of all the use cases. People will try to use software in ways that it was not intended. You can write code that will test functionality and you can write code that will test the code, unit tests. Then there’s refactoring, rewriting the code so that it’s cleaner and easier to understand. Why don’t you write the code clearly in the first place? As with any writing revision is important even in programming.

TDD is only one part of the development to deployment cycle. It looks useful and I’ll keep plowing through the book and hopefully it will begin to make sense.

More CSS (Actually CSS3)

Cascading Style Sheets (CSS) have come along way since I started doing web development. I had to design a simple front page for a client and, boy, howdy, is that hard to do. Trying to be minimalist requires a lot of thought. Also the this front page has to be responsive (look good on all devices and adjust to their parameters) that is the same content has to look good for a mobile device such as an iPhone, a tablet such as an iPad, or a laptop such as a MacBook Pro. Alternately, you could say Android, Android tablet, and Windows 10 laptop.

I finally pulled down The Book of CSS3 off the shelf and started reading it (I purchased it last spring). I learned all about media queries which allows a single page to adjust to the device it’s being viewed on. Each release of CSS standards comes with a number. The first version was CSS then CSS 2 then CSS2.1 and now CSS3. So what is a cascading stylesheet. It tells the browser how to render a web page. It tells it what fonts to show and what size, whether it’s normal, bold, italics, underline, or strikethrough. Or a combination of all of them. It can do much much more.

I’ve got a deadline for this site. I can get it done, but it is mentally exhausting. Still, it beats delivering pizzas.

CSS

The image overlaying the thumbnail can be translucent which I don’t want. The overlaid image can be solid where it isn’t transparent but then you can’t click on the thumbnail. I’ve tried various rearrangements of the items in the templates for the page. I can have one desirable trait but not both. HTML doesn’t allowed nested links but I removed those.

Of course this was all to solve the problem of even being able to tap on the thumbnail so it would take you to a new page on a mobile device which has a touchscreen. It needs to be a double tap solution. Because on a computer where you have hover with a mouse the text appears over the image. On mobile you tap and no text just goes to the new page. You need to be able to tap once to see the text then tap again to see the page. There are themes that actually do this. I may have to switch to one of them.

Is it time for Python 3?

I’d known that someday I’d have to start using Python 3. In fact I’ve wanted to but never got around to it. Part of it was the Python software I’ve been using, Plone is still in Python 2 and even with the most recent release of Plone 5 it’s still not there yet. They do plan on porting it to 3, but unsure of their timetable. Django on the other hand has been Python 3 for a little while now. Although I’ve wanted to move away from WordPress I hadn’t quite found a Django based CMS (content management system) that was as fully developed as WordPress. Plone is an awesome CMS but it is overkill for most of my clients, as they are individuals or small businesses.

Anyway, Python 3 was released in 2008, so it being 2015 I think it’s time. And I believe I have found a Django based CMS that will make it possible for me to move away from not only WordPress but also Plone. Both of them are ready go out of the box. This one isn’t and some assembly is required. Nor is it an exact replacement. It’s called Wagtail. I’d looked at some other Django based CMSes (including Django CMS), and I’d settled on Mezzanine for a while, but when I migrated to a new server on a python friendly host, I ran into some difficulties in re-installing Mezzanine. I’d resolved those difficulties but using Python 2.  There is no difficulty in using Python 3 though.

I’ve been making my development process more rigorous than I had in the past. I wasn’t so rigorous with WordPress which is written in PHP.  I need to be more so with Python as my work needs to be repeatable and better documented. I don’t develop in WordPress, I just customize child themes and add plugins if need be (which I try to avoid because updates wipe out  changes). There’s so many add ons and themes available, very little programming is necessary and many host providers have one click WordPress setups now and offer managed services (which is great).

To make my Python development process more rigorous I use virtual environments. This way I’m not polluting my OSes Python. And virtualenvwrapper is so much nicer than plain old virtualenv. I hadn’t forgotten about using version control. I’ve settled on git and I may write about that in future posts.

To use Python 3 make sure it’s installed on your computer whether it be Linux, MacOS or Windows. At a command prompt just type python3 –version and hit return. If it’s there you are good to go. You can make sure pip for 3 is installed by issuing the command pip3, though it’s not necessary when using virtualenvwrapper.

It’s fairly straightforward to getting virtualenvwrapper to create a python3 project just issue the following command:

$mkproject --python=path_to_python3 project_name
(project_name)user@ubuntu:~Devel/project_name$
$which python

to verify you are indeed using Python 3. And then you can pip install your little heart out.

Note: I’m not abandoning my existing WordPress customers. It’s a good platform and I’ve been working with it for over 10 years. It has a large development community and large user base. I don’t plan to take any new clients on for it, but it doesn’t mean I won’t. Since Wagtail requires more work I’ll have to seek out different clientele for it once I’m ready. This is a transition period for me. I plan on converting a few sites, the first of which is this one. I want to do more programming and I’m more productive in Python than PHP. It’s also easier for me to maintain my code and understand it. I don’t have to do a lot of programming with WordPress.

« Older posts

© 2022 Christopher Merle

Theme by Anders NorenUp ↑