Metaphysics and Software Design

Leave a comment

When I say that this is an experimental blog post I mean it.  I’m thinking out loud here.

Those who know me know that I am somewhat critical of some modern advancements in software design.  It’s not that I’m a Luddite or anything but the root of my discontent is that software and real life often do not match well.  Inbox by Google is a good example of this.  They refuse to put an “unread” feature into their software.  It messes with their blessed workflow.  Never mind that sometimes real life breaks the workflow, like if you accidentally click on an item. In the case of Inbox that accident means that you either have to open up other software (Gmail) or snooze the item you accidentally opened.

That’s an example of a mismatch of UX and reality.  But it also deeper than that.  Essentially any place where there is an interface between the human and the machine, from the user interface all the way to an API, there is going to be a mismatch between what the machine needs and how the human needs to interact with the machine.  And our response is often to make the human match the machine instead of the machine matching the human.  And given that the machine is often the interface between two humans, this seems backwards to me.  But I digress.

Consider the old interface with Magento 1.

How in the world does this break with metaphysics?  Well, one of the principles of Aristotelian metaphysics is that an object cannot actuate a potential that it does not possess.  In other words a ball cannot make water because it does not contain the potential for water.  But Oxygen and Hydrogen do contain the potential for water.  (Remember we’re talking about METAphysics, not physics.  It is very easy to get hung up on that.)

Going back to the example it could be argued that the code is bad code insofar as it breaks from metaphysics.  ArbitraryClass does not have the potential for a request.  How do we know that?  Because it’s Formal Cause (or Form) is not request-like, or request-ish.  And because there is a dissonance between its formality and efficiency, it is broken insofar as that dissonance occurs.  That’s not to say that it won’t work, but it’s workability will be a function of its alignment with its form.

Consider a triangle.  Have you ever seen a triangle?  No.  Never.  “You’re insane, Kevin,”  You might be thinking.  “I have seen triangles all over the place!”  Yes, you have seen examples of triangles, but they have never been perfect triangles.  A perfect triangle exists only in the immaterial sense.  What you have seen are objects that represent triangularity, but due to slightly curved lines, shifts on the paper, variations in the molecular density of the lead, among other things, you have never, ever in your life seen a triangle.

But you can still recognize a triangle based on its resemblance of triangularity.  In other words, it will still work as a triangle just like our code will still work like our code should.  But the degree of its success will be based on how well it confirms to its reality.

You might be thinking that this is all crap.  But let’s look at a more current implementation.

This example follows the principle that an object cannot give what it does not have.  As a result it is also “better” code.

But it also does a lot more than that.  It actually demonstrates some of the fundamental parts of Aristotle’s philosophy.

  1. It has an Essence or Form.  The DoSomethingInterface is its form, like triangularity.
  2. It does not have “request-ability” and so it must be given by something that does (the Dependency Injection Container).
  3. It has its material cause in its instantiation.
  4. It has efficient causality.  It “does something”.
  5. It has final causality.  It has a purpose.  (nobody intentionally creates un-purposed code)

And so forth.

This does not mean that you are required to code according to philosophy.  What it does seem to show is that the quality of code can be measured against how well the code fits against a logical metaphysical framework.

Bear in mind that this idea is new to me and there could very well be some disqualifying concept that renders this moot.  I’m, in a sense, debating myself in public.

But the flip side of this is that if this is correct, and good software does seem to follow good metaphysical flows, that may be able to be a framework for people to write code that is not only better, but works better in the real world.

But then again, this would turn programmers into Philosophers and God help us if that happens.  🙂


Validating Individual Shipping Methods

Leave a comment

Out of the box Magium will select the first shipping method on the screen. But there might be some times when you need to validate a particular shipping method, or force an error to be thrown if a shipping method does not exist. ’tis now easy to do. use MagiumMagentoAbstractMagentoTestCase; class ShippingTest extends AbstractMagentoTestCase { … Continue reading “Validating Individual Shipping Methods”

Powered by WPeMatico


Asserting page load times in Magento with Magium

Leave a comment

Validating SLAs (Service Level Agreements) is often part of executing browser tests. With Magium you can now include page timings as part of your test. Say, for example, that part of your SLA is that a page must be rendered in less than 5 seconds. This is done by using the TTFBLoadedLessThan, DOMPageLoadedLessThan or DOMContentLoadedLessThan … Continue reading “Asserting page load times in Magento with Magium”

Powered by WPeMatico


Validating that page assets are cached

Leave a comment

It’s not just HTML elements that need to be tested, and sometimes not even testing that images or CSS files are being tested. Sometimes you need to test things like server configurations. Magium’s position is that there are a wealth of different areas where browser testing can benefit your organization. Validating browser testing configurations is … Continue reading “Validating that page assets are cached”

Powered by WPeMatico


Drawing floating columns/bars in Flot

Leave a comment

Let me say first of all, that I mostly like Flot as a charting application. It provides a lot of charting functionality and is reasonably good looking.

But sometimes it is a bit of a pain to deal with. Case in point; I wanted to create a chart that had floating columns (Flot, in my opinion incorrectly, calls vertical columns, bars). In essence, what I wanted was this:

2016-04-25_2000

Well, it can be done but, after I spent far too many hours trying to figure out how, it is not exactly clear how to do it.

The first thing I learned was that the data format for a bar is the opposite of what one would intuitively expect.  That doesn’t mean that it’s wrong (it make sense in retrospect), it’s just not intuitive.

If you want to float a bar/column in Flot you do it in the following format:

I had figured that min would come before max.  But that does not.

But that does not completely solve the problem because Flot does not allow you to control how the bottom bar is rendered; it is automatic.  And that automatic rendering removes the bottom border with no option to force it.  The result of the previous JavaScript array is:

2016-04-25_2005

That’s not horrible, but the lack of a bottom looks a little cheap.  The solution?  Create a second item in your dataset like this:

It feels a little dirty but it works.  You are creating a 1px border by putting another column with no height immediately below your column.  This is the result:

2016-04-25_2000


ChromeDriver hangs with Selenium Server and Xvfb

Leave a comment

I have spent several hours working on an issue while running Selenium Server under Xvfb with ChromeDriver.  There would basically be a 30 second timeout when connecting to Selenium Server from WebDriver with this being the exception:

I strace()ed the process and it came down to a read() on a pipe sitting there, but I could not figure out why.  Eventually I worked my way into the temp directory for the hung process, /tmp/.com.google.Chrome.v0ul8E.  In there is the file chrome_debug.log.   In that file was one entry:

Searching Google, I came upon this discussion on GitHub.  The problem they noted was for Docker, and I wasn’t running Docker, but the problem was very similar.  The solution was to set the environment variable: DBUS_SESSION_BUS_ADDRESS=/dev/null.

I made the change to my systemd service file

I’ve run about 300 tests so far with no timeouts. Yay!


Browser Testing Twitter OAuth Accounts

Leave a comment

I added a Twitter OAuth integration in @magiumlib so you can easily do authentication automation. pic.twitter.com/NjHvvRDG9G

— Kevin Schroeder (@kpschrade) April 6, 2016

This is a simple library to help browser tests perform OAuth logins to Twitter.

To install

To use:

Setting the username and password

There are two ways to set the username and password

In code

In configuration

Create the file /configuration/Magium/Twitter/Identities/Twitter.php and enter the following:

Note that you should be familiar with AbstractConfigurableElements to do this

Not in Magium

This library doesn’t require Magium to run. Well, actually it does, but it doesn’t need the abstract test class. It’s a little verbose, but this is what it would look like (you could also use a DIC to manage this).

Powered by WPeMatico


Logging in to the Magento Admin UI

Leave a comment

Logging in to the admin UI is fairly simple, but there are a few things you need to do ahead of time. The actual functionality looks like this:

That is all that is needed to log in… from the perspective of an action. But you do need to configure it to work in your environment. There are two ways of doing that.

The bad, but easy way

The easiest way is to configure your admin identity and theme directly in your test.

That will work, but what if something changes. Then you’ll need to go and change each and every instance where you did that. For that reason you should choose the

Marginally more complicated, but infinitely better way

This involves using the configurable nature of Magium. There are two files you will need to create in the base of your project.

  1. /configuration/Magium/Magento/Themes/Admin/ThemeConfiguration.php
  2. /configuration/Magium/Magento/Identities/Admin.php

This file will contain the configuration information for the theme. In this case the only thing we need to change is the baseUrl.

/configuration/Magium/Magento/Themes/Admin/ThemeConfiguration.php

Next up you will need to set the admin username and password.

/configuration/Magium/Magento/Identities/Admin.php

From there any test that requires the admin will be automatically configured to work with these credentials and with this URL.

If you still need some help understanding configurable elements you should check out this video.

Powered by WPeMatico