Software Engineer

I am a Software Engineer. I have a Bachelor (Honours) of Science in Information Technology from the University of Sunderland - Class of 2003. I have been developing software since 2001 when I was offered a role at CERN as part of their Technical Student Programme.

By 2016 I had grown really tired of the software industry and by the end of 2019 Apple killed whatever excitement I had left. I am not sure what the next 10 years will bring. What I do know is that my apettite to do work that is impactful has only grown bigger and stronger. Great people make me tick more than anything.

I am also tired.

Revelations ...O Is For Object (Part 3)

/**
     * It's a revelation
     */
    public final class Route
    {
        public static final class RouteBuilder
        {
            private final Destination from;
            private final Destination to;
            private Calendar date = Calendar.getInstance();
            
            public RouteBuilder(Destination from, Destination to)
            {
                this.from = from;
                this.to = to;
            }
            
            public RouteBuilder onDate(Calendar date)
            {
                this.date = date;
                
            return this;
            }

            public Route build() {
            return new Route(this.from, this.to, this.date);
            }
        }

        private final DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");
        
        private final Destination from;
        private final Destination to;
        private final Calendar date;

        private Route(Destination from, Destination to, Calendar date)
        {
            
            this.from = from;
            this.to = to;
            this.date = date;
        }

        private void appendDate(StringBuilder builder, Date date, DateFormat dateFormat) {
            builder.append( dateFormat.format(date) );
        }

        private void appendCode(StringBuilder builder, String code) {
            builder.append(code);
        }

        public int via(TransportMethod method) {
        return method.route(this.from, this.to, this.date);
        }
        
        public String bookingCode()
        {
            StringBuilder builder = new StringBuilder();
            
            this.appendCode(builder, this.from.code());    
            this.appendCode(builder, this.to.code());    
            this.appendDate(builder, this.date.getTime(), this.dateFormat);
            
        return builder.toString();
        }
    }

    /**
     * And a well thought design
     */
    public class RouteTest
    {
        private static final DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");  
        private static final Calendar now = Calendar.getInstance(); 
        private static final String BOOKING_CODE = 
            String.format("%s%s%s", 
                    Destination.EDINBURGH.code(), 
                    Destination.LONDON.code(),
                    dateFormat.format(now.getTime()));
        
        @Test
        public void via() throws Exception
        {
            TransportMethod transportMethod = TransportMethods.BUSINESS_FLYING;                
            Destination from = Destination.EDINBURGH;
            Destination to = Destination.LONDON;

            Route route = new RouteBuilder(from, to).build();

            Assert.assertEquals(BOOKING_CODE, route.bookingCode());
            Assert.assertEquals(500, route.via(transportMethod));
        }
    }

This isn’t about time, money or need. This is about software design

The code above isn’t “better” because it’s eloquent. Nor because it adheres to SOLID principles. It’s because it uses the most basic concept in OO. The Object.

It didn’t derive thinking about extensibility, reusability, maintenance or testing. It wasn’t conceived after a long architectural design discussion. This is OO at its purest form.

Don’t ignore it. Embrace it. It’s liberating.

Source