Robert Baillie

Subscribe to Robert Baillie feed
More than 2 decades of writing software, and still loving it...
Updated: 15 hours 21 min ago

Lightning Web Components - Conditional formatting and iterators

Thu, 2018-12-27 07:11
One of the really elegant parts of Lightning Components was the ability to conditionally apply classes based on data. This is something that is no longer available to us, as the expressions we are allowed to put into templates are now limited to either: A property of the Javascript class (or a sub-property that can be referenced through a top level property). A getter, that accepts no parameters. I’ve already mentioned a change in this area in this blog post about building re-usable components, but I felt it was time to drill into this just a little further... The scenario Let’s say we want to render a list of objects. There’s a flag 'isSelected' on each of the records, and if that flag is set we want to change the rendering for that particular record. JSON data: [ { "id" : 1 , "name" : "Anne" , "isSelected" : false }, { "id" : 2 , "name" : "Bob" , "isSelected" : true }, { "id" : 3 , "name" : "Carla" , "isSelected" : true } ] Required Output: <ul> <li...

Lightning Web Components - Events, and listening to your children

Thu, 2018-12-20 09:13
Another fantastic inclusion in Lightning Web Components is the completely reworked events model. De-composing functionality and building smaller, and more generic building blocks has become much simpler and much more intuitive. In the world of Lightning Components I never got on with events. The idea of adding a Salesforce configuration for an event, registering events on the dispatcher template, and then registering listeners on the receiving template seemed really cumbersome. And then added onto that was the differences in syntax between component and application events. They just felt really unnatural. In Lightning Web Components all this has become significantly simpler, and much more in-keeping with the standard HTML / Javascript model. We've already seen how we can use @api allow state to be passed into our components. Now we're talking about notifying our parents when events occur. I could go into deep detail on how this is done, but the documentation on this area is...

Lightning Web Components - Unit Testing immediate impression.

Thu, 2018-12-20 04:03
One of the things I’m most excited about in Lightning Web Components is the ability to write Unit Tests for the components. The unit testing framework of choice is Jest, and it looks well suited. Not least it’s the framework of choice for Facebook, and describes itself as well suited to React apps. Why should that matter? Well, React is a 1-way bound Javascript framework - and so is LWC. So I was looking forward to get into Unit Testing, following the documentation for testing wired components Unfortunately, the documentation didn’t work out for me, and it looked like there’s a couple of mistakes in there: The example ‘getRecord.json’ file isn’t valid JSON. In order for the file to work, the field names need to be surrounded in double quotes. I.E. Instead of: // getRecord.json { fields: { Name: { value: "DYNAMO X1" } } } The file should be: // getRecord.json { "fields": { "Name": { ...

Lightning Web Components - @api, slots and getters

Wed, 2018-12-19 05:49
I've blogged about a few of the behaviours of Lightning Web Components, but the proof is really in building useful bits. What happens when you actually try to make a re-usable component? For our example, we'll rebuild 'ui:message'. A now (seemingly) defunct base component that would render a message in a box that is coloured based on the 'severity' of the message being shown. In the original it could be set to 'closable', although we're going to ignore that and focus on just the rendering of it. In a Lightning component we would use it like this:Original usage - Lightning Component <ui:message title="Error" severity="error" >{!v.errorMessages}</ui:message> Ideally, the version we will create, would be used like this:Desired usage <c-message title="Error" severity="error" >{errorMessages}</c-message> Looks pretty straightforward, and actually - it is. Just as long as we know about a few simple concepts. Before we go into them, let's see what a working...

Lightning Web Components - The subtleties of Tracking and Wiring

Tue, 2018-12-18 07:02
Following on from yesterday's investigations into the behaviour of '@track', and its effect on untracked properties, I figured I should expand my remit to '@wire'. My main reason for that was the statement in the documentation: In the wire adapter’s configuration object, prefix a property with $ to reference a property of the component instance. The $ prefix tells the wire service to treat it as a property of the class and evaluate it as this.propertyName. The property is reactive. If the property’s value changes, new data is provisioned and the component rerenders. This comment relates to code along the lines of: @api recordId; @wire(getRecord, { recordId: '$recordId', fields }) contact; The bit that really piqued my interest was 'The property is reactive'. In all the examples, it looked like the property being referenced was always tracked or set as an api field (the latter implying the former) That's the case in the above example - the property passed as a...

Lightning Web Components - the art of Tracking

Mon, 2018-12-17 10:51
On Friday I wrote an excited blog post on the introduction of Lightning Web Components. One of the things I mentioned was that I didn't quite get how '@track' was supposed to work Since then, I've found the documentation (add /docs/component-library/documentation/lwc/lwc.get_started_introduction to the end of your Salesforce URL), read it, got confused by my memory, wrote a test-rig and looked at it all in depth. On the surface, it's simple, but there are some complications, which were the cause of my confusion... In the documentation it says the following: Both @track and @api mark a property as reactive. If the property’s value changes, the component re-renders. OK, nice and simple. So what does that mean? A single untracked property Testing with a simple component that contains a single property that is not tracked I found the following behaviour: Javascript component export default class TrackExperiments extends LightningElement { primitiveUntracked; ...

Lightning Web Components - the dawn of (another) new era

Fri, 2018-12-14 12:18
Salesforce have a new technology. Lightning Components look like they’re on the way out, and are being replaced with a new technology ‘Lightning Web Components’. The reasons behind that, and the main principles behind its design are covered very nicely in this article on developer.salesforce.com. From that we can then get to a series of examples here. (Note: some of the code snippets used below, to illustrate points, are taken from the recipes linked above) Now I’m a big supporter of evolution, and I love to see new tools being given to developers on the Salesforce platform, so, with a couple of hours to play with it - what’s the immediate impression? This is an article on early impressions, based on reviewing and playing with the examples - I fully expect there to be misunderstandings, bad terminology, and mistakes in here - If you're OK with that, I'm OK with that. I admit, I got excited and wanted to post something as quickly as possible before my cynical side took over. So...

LinkedIn, and the GDPR age

Wed, 2018-11-28 13:34
I should start this post by saying I’m neither a lawyer, nor a GDPR expert.  Possibly both of those facts will become massively apparent in the text that follows. Also, I’m not a LinkedIn Premium user - so it’s possible I’m missing something obvious by not having access to it. But anyway, I’ve been thinking about how LinkedIn fits into a GDPR world, and it doesn’t something doesn’t seem quite right to me at the moment. LinkedIn are in the data business, and they’re very good at protecting that asset.  They tend to be (quite rightly) pro-active in stopping people from extracting data from their systems and pushing it into their own systems. As such, businesses (recruiters particularly) are encouraged to contact directly within LinkedIn, and they are offered tools to discover people and commence that communication. Unfortunately, this lack of syncing between LinkedIn and in-house systems can cause a big problem with GDPR. That is: What happens if someone says to a recruitment...

Things I still believe in

Fri, 2018-10-19 09:49
Over 10 years ago I wrote a blog post on things that I believe in - as a developer, and when I re-read it recently I was amazed at how little has changed. I'm not sure if that's a good thing, or a bad thing - but it's certainly a thing. Anyway - here's that list - slightly updated for 2018... it you've seen my talk on Unit Testing recently, you might recognise a few entries. (opinions are my own, yada yada yada) It's easier to re-build a system from its tests than to re-build the tests from their system. You can measure code complexity, adherence to standards and test coverage; you can't measure quality of design. Formal and flexible are not mutually exclusive. The tests should pass, first time, every time (unless you're changing them or the code). Test code is production code and it deserves the same level of care. Prototypes should always be thrown away. Documentation is good, self documenting code is better, code that doesn't need documentation is best. If you're getting bogged...

Promises and Lightning Components

Wed, 2018-10-03 08:41
In 2015, the ECMA specification included the introduction of Promises, and finally (pun intended) the Javascript world had a way of escaping from callback hell and moving towards a much richer syntax for asynchronous processes. So, what are promises? In short, it’s a syntax that allows you to specify callbacks that should execute when a function either ’succeeds’ or ‘fails’ (is resolved, or rejected, in Promise terminology). For many, they're a way of implementing callbacks in a way that makes a little more sense syntactically, but for others it's a new way of looking at how asynchronous code can be structured that reduces the dependancies between them and provides you with some pretty clever mechanisms. However, this article isn’t about what promises are, but rather:  ‘How can Promises be used in Lightning Components, and why you would want to’. If you want some in depth info on what they are, the best introduction I’ve found is this article on developers.google.com In...

Throw it away - Why you shouldn't keep your POC

Sat, 2014-12-13 04:32
"Proof of Concepts" are a vital part of many projects, particularly towards the beginning of the project lifecycle, or even in the pre-business case stages.They are crucial for ensuring that facts are gathered before some particularly risk decisions are made.  Technical or functional, they can address many different concerns and each one can be different, but they all have one thing in common.  They serve to answer questions.It can be tempting, whilst answering these questions to become attached to the code that you generate.I would strongly argue that you should almost never keep the code that you build during a POC.  Certainly not to put into a production system.I'd go so far as to say that planning to keep the code it is often damaging to the proof of concept; planning to throw the code away is liberating, more efficient and makes proof of concepts more effective by focussing the minds on the questions that require answers..Why do we set out on a proof of concept?The...

The opportunity cost of delaying software releases

Thu, 2014-10-09 06:02
Let me paint a simple picture (but with lots of numbers). Some software has been built.  It generates revenue (or reduces cost) associated with sales, but the effect is not immediate.  It could be the implementation of a process change that takes a little time to bed in, or the release of a new optional extra that not everyone will want immediately. It is expected that when it is initially released there’ll be a small effect.  Over the next 6 months there will be an accelerating uptake until it reaches saturation point and levels off. Nothing particularly unusual about that plan.  It probably describes a lot of small scale software projects. Now let’s put some numbers against that. At saturation point it’s expected to generate / save an amount equal to 2% of the total revenue of the business.  It might be an ambitious number, but it’s not unrealistic. The business initially generates £250k a month, and experiences steady growth of around 10% a year. What...

How do I type e acute (é) on Windows 8

Wed, 2014-10-08 09:32
I keep on forgetting how to type é on Windows 8 (I used to CTRL+ALT+e, but that's now often reserved for the Euro symbol) I then tend to run a search on Google, and end up being pointed towards 8 year old answers that point you to character map, options in old version of word, or the old way of typing the extended ASCII character code. They all suck. And then I remember - it's easy. You start by pressing a CTRL + a key that represent the accent, then type the letter you want accented. For example, CTRL + ' followed by e gives you é. Brilliant! The great thing about using this technique is that the characters you use (dead letters) are representative of the accents you want to type. This makes them much easier to remember than the seemingly random character codes Here are the ones I know about: KeystrokesAccent typeExamplesCTRL + 'acuteéCTRL + `graveèCTRL + SHIFT + 6 / CTRL + ^circumflexêCTRL + ,cedillaçCTRL + ~perispomeneõCTRL + SHIFT + 7 / CTRL + &Diphthongs / others a =...

Gamification to level 80

Fri, 2014-01-31 04:14
Since the end of July last year I've been test driving one of the latest online tools that hopes to change your life by giving you the ability to store your task lists. Wow. What could be more underwhelming, and less worthy of a blog post? Well, this one is different.  This one takes some of the huge amount of thinking on the behaviour of "millenials" and "Generation Y", adds a big dose of social context and ends up with something quite spectacular. This is the gamification of task lists, this is experience points and levelling up, buying armour and using potions, this is World of Warcraft where the grinding is calling your mam, avoiding junk food or writing a blog post. This is HabitRPG.The concept is simple, you manage different styles of task lists.If you complete entries on them you get experience points and coins.If you fail to do entries them you lose hit points. Depending on on whether you're setting yourself realistic targets and completing them you either level up, or...

BBC and web accelerators don't mix

Wed, 2013-09-18 02:53
Do you have a problem with the BBC website? Even though you're based in the UK it seems to have a lot of adverts for American companies on it? And it's not that you don't like American companies, it's just that you've already paid your licence fee and that means that you shouldn't have to see any adverts at all.Even worse than that, because it thinks you're not in the UK, it won't let you access any of the iPlayer content! At some point in the last few weeks that started to happen to me on my Android (Nexus 10, no less) tablet. Thankfully I managed to solve it. A quick scan of the BBC help seemed to just direct me to my ISP (they may route you through foreign / non-UK servers - I knew this wouldn't be true as my desktop works OK, and it doesn't sound like BT). A quick mail to them seemed to confirm my fears - no problem there. A mail to the BBC was never going to be much use. I don't blame them, they have a lot of people to deal with and none of them pay a subscription fee that's...

Redundancies should come with a pay rise

Sun, 2013-09-01 02:21
As far as I can see, there is only one reason why a company should ever make redundancies.Due to some unforseen circumstances the business has become larger than the market conditions can support and it needs to shrink in order to bring it back in line.Every other reason is simply a minor variation or a consequence of that underlying reason.Therefore, if the motivation is clear, and the matter dealt with successfully, then once the redundancies are over the business should be "right sized" (we've all heard that term before), and it should be able to carry on operating with the same values, practices and approach that it did prior to the redundancies.If the business can't, then I would suggest is that it is not the right size for the market conditions and therefore the job isn't complete.OK, there may be some caveats to that, but to my mind this reasoning is sound.In detail:When you reduce the headcount of the business you look for the essential positions in the company, keep those,...

Agile and UX can mix

Thu, 2013-08-29 05:19
User experience design is an agile developer's worst nightmare. You want to make a change to a system, so you research. You collect usage stats, you analyse hotspots, you review, you examine user journeys, you review, you look at drop off rates, you review. Once you've got enough data you start to design. You paper prototype, run through with users, create wireframes, run through with users, build prototypes, run through with users, do spoken journey and video analysis, iterate, iterate, iterate, until finally you have a design. Then you get the developers to build it, exactly as you designed it. Agile development, on the other hand, is a user experience expert's worst nightmare. You want to make a change to a system, so you decide what's the most important bit, and you design and build that - don't worry how it fits into the bigger picture, show it to the users, move on to the next bit, iterate, iterate, iterate, until finally you have a system. Then you get the user experience...

Database Build Script "Greatest Hits"

Thu, 2013-08-08 10:27
I know its been a quiet time on this blog for a while now, but I've noticed that I'm still getting visitors looking up old blog posts. It's especially true of the posts that relate to "The Patch Runner". Many of them come through a link from Wilfred van der Deijl, mainly his great post of "Version control of Database Objects". The patch runner is my grand idea for a version controlled database build script that you can use to give your developers sandbox databases to play with as well as ensuring that your live database upgrades work first time, every time. It's all still working perfectly here, and people still seem to be interested, so with that in mind I've decided to collate them a little bit. basically provide an index of all the posts I've made over the years that directly relate to database build scripts, sandboxes and version control. So, Rob's database build script 'Greatest Hits': On the basic idea of building a database in an agile mannerOn how you might start...

A reading list for our developers

Thu, 2013-08-08 10:27
An idea I'm thinking of trying to get implemented at our place is a required reading list for all our developers. A collection of books that will improve the way that developers think about their code, and they ways in which they solve problems. The company would buy the books as gifts to the employees, maybe one or two every three months. Some questions though: Is it fair for a company to expect its employees to read educational material out of hours? Conversely: Is it fair for an employee to expect to be moved forward in their career without a little bit of personal development outside the office? If anyone has any books out there that they'd recommend - please let me know. Otherwise, here's my initial ideas - the first three would be in your welcome pack: Update:Gary Myers came up with a good point, being that any book should really be readable on public transport. That probably rules out Code Complete (although I read it on the tube, I can see that it's a little tricky),...

Ideas for improving innovation and creativity in an IS department

Thu, 2013-08-08 10:27
At our work we've set up a few 'action teams' to try to improve particular aspects of our working environment. The team that I'm a member of is responsible for 'Innovation and Creativity'. We're tasked with answering the question "How do we improve innovation and creativity in IS?" - How we can foster an environment that encourages innovation rather than stifles it. As a bit of a background, the company is a a medium sized (2,500 plus employees) based mainly in the UK, but recently spreading through the world, the vast majority of whom are not IS based. The IS department is about 100 strong and includes a development team of 25 people. It's an SME at the point where it's starting to break into the big-time and recognises that it needs to refine its working practices a little in order to keep up with the pace of expansion. We met early last week and have put together a proposal to be taken to the senior management tier. I get a feeling it will be implemented since our team...

Pages