Friday, 24 June 2016

Software Engineering : C++14/make_shared & Factory Create Pattern

I have a C++ issue, it's not often I can pick fault, but this is one of them... For years, I've used the factory create pattern; or at least my take on that pattern.  

Whereby I make the constructor private, or the whole class "Uncopyable/Uncreatable", and then I add a new static function which returns the class wrapped into a smart pointer.

By doing this, I get the advantage that no-one can use outdated "new" calls on it, and I drastically reduce the potential for third party memory leak creation/exploitation.

I can still do this with C++14, however, for a while now authors have recommended using "std::make_shared".  Their points are valid, but they break my factory creation pattern.  Which has much more to offer me than just using "make_shared" or whatever smart pointer creation template.

Lets take a look...


So, we have the class, but we're creating and deleting it in the old style, anyone forgetting to perform that delete will leak memory.


There, we can implement creating the class instance with a smart pointer...


A big change next however, we make the constructor private, to absolutely stop other programmers creating instances of our class with "new" and so totally negating anyone creating the class and potentially forgetting to delete it.

So we offer the programmer the static create function, which returns the shared pointer wrapped class... At least, that was the idea, as we can see, it utterly fails, because the std::make_shared template class is not a friend of our "foo" class.

Finally, we have to take a step back, to use the create, and hence enforcing our whole factory create pattern, we have to return this smart pointer wrapped instance after using "new".  This is fine, it is the same as "std::make_shared", but feels like a retrograde step.


Tuesday, 21 June 2016

Project - Socket 775 to Socket 771 Xeon - Update

As an update to my original post, I got another socket 775 motherboard and took a video of how to cut the tabs off the socket, making it able to accept a socket 771 Xeon, but doing so with the original chip in place, to protect the socket pins.

Check it out here:



Sunday, 19 June 2016

RIP Anton Yelchin

Little bit stunned by the news of Anton Yelchin's accidental death...


Friday, 17 June 2016

Gaming: Snake.IO

Is this a bad habit forming?


Find me, sometimes, on snake.io

Wednesday, 15 June 2016

My Reviews, CPU's and Books

Well folks you'll have no-doubt noticed I'm getting a fair few reviews out there, mainly through my YouTube channel, but also via Amazon where you'll find me fiddling and filming many items.

However, I wanted to just take a moment, to say; even though I get these items, if they are rubbish, I'll tell you.  I reserve all my own editorial rights, and though you can see something as cheap or free as a viable worthy thing, I'm still going to tell you if they fail miserable; simply because that's what people need to know.

You need to know if the items you're getting are utterly rubbish or not, whether it's worth spending money on, or even if it's cheap and decent, or just "good enough"; you know as a stop gap measure.

So expect many more things to float this way soon... I have an Android Tablet to review, a pretty nice looking Carry-All for gaming/software purposes; as someone on the move with many software facets, it'll be nice to have a bag with actual pockets for CD's or DVDs... and yes, I still use optical media!

I am also looking at filming a new-updated series about writing your own CPU, my previous posts here about it are perhaps my most viewed pieces, and the YouTube videos about them (which are silent) are pretty popular too.... But they're not perfect, they are as I say, Silent, they are perhaps incomplete, and to be honest they need updating to C++14.

There is also another reason for me to push out a new software series anyway, and that is that I'm constructing a book, yes me... An author!... I've been toying and trialling different styles for a technical book for sometime, a book for office use, to teach others to think and code as I do.

The reason being, we're hiring graduates, and they don't have the experience firstly, but now they're all very much younger than myself, and they don't have the grounding in computing.  When they're sat in front of an eight core, 3Ghz PC with 16GB of RAM, and they describe it as "slow", I just want to slap them around the back of the head with a rolled up news paper.

So, I started a document about how they should perhaps approach programming, gave some algorithms as to how they can see how something can be slow, but actually their machines are quite fast!... This was a success, and at least two of the people hired around me have stuck around, despite being very young graduates with very narrow fields of experience, they've become pretty good jobbing programmers.



I feel therefore I might make a more experience orientated programming book, many of them out there are tutorials, or "beginners", or even expert friendly, and many of them impart good knowledge, but I don't believe many expand or impart skills to the reader, and it's that skills bit which is difficult.


Difficult because in text, you're reduced to being very verbose, a picture speaks a thousand words, but a picture is not going to explain how to code all the time, so I'm struggling with word count and audience attention span at the moment, at least with my initial drafts.

Drafts?... Multiple?... Yes, because, like with my blog posts, I'm breaking this whole thing down in to different texts, a basic, a couple of middling and one expert tome, it what I'm aiming for at the moment.  Backed up with an initial FREE! Introduction set.  I also plan to perhaps have a free book about cross-platform work too, or the cross-platform development environment, and then a paid for book about actually doing cross-platform work.

The idea being, the reader can boot-strap into my text for free, then cherry pick what sections they may want.

I'd not want the whole series to cost more than a few pounds, we're not even talking tens of pounds, literally the whole lot for less then £9.99.  But each individual part I do want to charge for, a few pounds at a time, so to speak.

And why read my stuff?.. Well, if not to get a job with me, to at least feel more than just a programming, to take that step towards being a developer, to being better, and thinking better of the work you do.

Also to let me feel a little self-important... Right?... that's the best bit!... Be Xel trained today!

Monday, 13 June 2016

Electronics Tinkering : Project Plan #1

I've been wanting to tinker with some electronics for ages, and in my store, I have some Z80 CPU's and lots of TTL logic.  But before I dive into that, and since I'm totally untrained, I thought I'd have a play about with my soldering iron and see what I could mash together.

My plan therefore is to desolder a PS2 connector from one of the Socket 775 motherboards I killed, and to connect it to an arduino uno to read the pins.


Looking at this, I can mount the PS2 connector to a project board, solder on a set of headers and wire each pin to a known point on the header.

From there I can use jumper cables from my breadboard to bridge from the headers on the project board to the arduino.

At least, this is the theory.

The first thing I need to worry about is the clock, I have no idea what the clock rate is, if I need a crystal, or if a capacitor charging & discharging will do, or even if I can create the signal from a GPIO pin or PWM pin from the arduino... I'll have to look into that and let you all know.

My rough schematic is going to look like this on the project board:


The outer shell will be going to ground, and it has four feed to solder.  Then the four pins seem to point to clock, Ground, VCC and Data.  I'm not clear on which of the pins below become the sockets, so I'll have to insert something into the socket holes and check for continuity to the pins to know the order.

But each group of four will be soldered to a header, which I've marked read and blue.  One will be the upper set of ports, the other the lower.  I'm not going to distinguish keyboard/mouse because I just want a keyboard signal.

So, a bit of soldering with my new iron.  I'm going to have to de-solder with it too.

Below follows a list of the links I'm interested in looking through:

From the Wikipedia entry (yes I read Wikipedia) states:

"Communication is serialsynchronous and bidirectional.[1] The attached device generates the clock signal. The host controls communication using the clock line; when the host pulls the clock low, communication from the device is inhibited."


Saturday, 11 June 2016

Tech Rant - Twitch.tv Fix Your Filter

You already know I stream a lot to Twitch.tv, despite making zero income or anything and have pretty much no viewers, it lets me at least think I'm involved in something - seriously guys, I get like 100 views a day on here, go check out my twitch, and my YouTube!  They're linked on the right by the tips jar - which you could also use.. *cough* cheap bastards.

Anyway, what's my problem today?... Well, I've had ANOTHER copyright strike on Twitch, this is the second, the first time was a false positive, it detected god knows what from a truly free royalty free music source.  As a consequence I stopped steaming with music, despite nearly everyone else being able to do so, I didn't want to take the chance.

Today's strike though beggars belief.  It reckons I'm playing Shaggy's rendition of "Mr Bombastic"... I am not doing any such thing, this is a video of me talking... and Tinkering with a server...

Do I look like Mr Bombastic?  Am I totally Fantastic?

I am getting so annoyed with this, because when you submit your appeal, it does not go to twitch, or a forum, it goes off to some mindless entity and you get this horrible worrisome message about their submitting your details to some court in California.

News flash twitch, you'll have to drag me kicking and screaming to get me to go to California, and also the sound doesn't contain any music, and I certainly don't sing!

Idiots....