https://barelycompetent.co.za/https://barelycompetent.co.za/favicon.pngBarely Competenthttps://barelycompetent.co.za/Ghost 3.17Sat, 30 May 2020 14:11:34 GMT60First, I do not sit down at my desk to put into verse something that is already clear in my mind. If it were clear in my mind, I should have no incentive or need to write about it. We do not write in order to be understood; we write]]>https://barelycompetent.co.za/delaying-the-inevitable-a-case-against-extending-lockdowns/5e8ffcfc5ba4860038f6c3c5Sun, 12 Apr 2020 21:04:49 GMTFirst, I do not sit down at my desk to put into verse something that is already clear in my mind. If it were clear in my mind, I should have no incentive or need to write about it. We do not write in order to be understood; we write in order to understand.

~ C. S. Lewis

I never intended to write about the pandemic. Nor did I think it appropriate to do so, as I have no qualifications in either epidemiology, virology, economics or politics. I am the textbook definition of a layman.

So why am a writing this then? Mostly, because I need to work through what is happening in my country, and the world, but most importantly I want to present an argument for preserving life. In order to do that effectively I need to first lay some groundwork.

Groundwork

What is the purpose of a lockdown / stay-at-home order?

The reason for the lockdown / stay-at-home orders are to "flatten the curve". What this means is that we have a finite amount of resources, such as hospital beds, ventilators and facilities to deal with the rapid spread of virus, and that if we delay the spread of the virus we can deal with the virus more effectively and in smaller numbers.

Will a lockdown prevent me or my loved ones from getting the virus?

The answer is probably not. We're all going to be personally affected in some way, shape or form. We will either get infected, know of someone who gets infected or deal with loss of some kind. The purpose of lockdown is to "flatten the curve", not prevent the total spread of the virus, but mitigate how fast it spreads.

My lockdown experience in context

In South Africa, where I reside, our lockdown has been extended for another two weeks, to make it a total of five weeks. At the time of writing we have had just under 2200 confirmed infections and just below 30 deaths. South Africa went in lockdown a lot quicker than most countries and we've locked down the economy almost completely, with only "essestial" items being sold. Selling things considered "non-essential" is illegal (at least for now). Only pharmacies, supermarkets, gas stations, financial institutions such as banks and insurance companies and emergency services, such as medical, security and police services are allowed to operate during the lockdown.

These businesses selling "essential" items, are also restricted in what they are allowed to sell, even if it forms part of their normal inventory. You cannot buy toys for your kids during this time, even if they are right next to the bread isle in your local supermarket as they are not deemed "essential". It makes no sense, why buying a toy whilst you are in the shop will spread the disease further, but I doubt we will get a sufficient explanation for that. South Africa has also banned takeaways, online shopping that is not food or medicine related, and forbid the trade of alcohol and cigarettes.

Consider how you provide for your family

People automatically switch off when you talk about the economy. When anybody mentions the economy during this pandemic, you will automatically be labelled evil, heartless and putting money over lives. People will claim that you want to kill your grandparents, because of the stock market, or "evil" corporations.

To try and prevent the conversation from degenerating to that point, let's take away the "evil" corporations, the stock market and whatever you consider to be "immoral" when you think about the economy. Let's pretend for a second that giant scary corporations, evil stock markets and those damn bankers that everyone loves to hate, do not exist or matter.

Ask yourself for a second. How do you provide for your family? How will losing your main source of income affect your ability to provide for your family? How long can you survive without any income? Will you be able to sufficiently feed your family if your income streams dry up? If you do not lose your income, what will happen if your close family members, not residing with you, loose their income? Will you be able to feed the extra mouths? Or are you fine with leaving them to their fate?

The Case Against Extending Lockdowns

Waiting it out

The case for lockdown seems very compelling. It seems like if we can just wait out the virus, then we can all just get back to our lives. Like it used to be. Except it is not going to be like it used to be. That little coffee shop with the baked goods and the good coffee might not survive the financial hardship of closing down for a month or more. The family owned restaurant with the great steak is no longer open, because they could not afford to pay their workers and/or their debt. That is just problems that affect you, can you imagine how they must feel? Now, I can already hear people saying that if those businesses continue to operate, that their staff could be wiped out by the virus. That is somewhat plausible, but the evidence does not seem to suggest that the whole world will die if they do get the virus.

None of the medical professionals as far as I can tell are suggesting that a lockdown will make the virus go away. Your chances of getting the virus are still very good, based on how easily the virus spreads. It means you will in all likelihood still contract the virus, but not as soon as you might have otherwise. However, it seems that people seem to have grabbed on to this false sense of security that a lockdown will solve everything and that they will be magically immune to this virus as long as the lockdown is in place. People are so convinced of this false sense of security that they will accuse people that break the lockdown rules; those hardened criminals walking their dog in the park with no-one within a 100m vicinity of them; of murderous intent.

Waiting it out, will not be an easy task, nor is it feasible to do so, especially if you consider it might take 18 months or longer to get a vaccine. I am not saying that we are not capable of producing vaccines quicker, but we need to be realistic here. Creating a vaccine, it is not an easy thing to do, it is not like a cake recipe, that once you come up with the ingredients, you can just hand over the recipe to everyone. Vaccines and medicines behave differently on different people. There are risks involved with any sort of medication, even with well-established and "safe" medicines, incorrect dosages can cause quite severe side-effects, including death and permanent disability.

Getting sick is part of life

As heartless as it sounds, getting sick is part of life. You will at some point in your life get sick, it might even be the worst thing that has ever happened to you, but you cannot simply change this fact of life.

Disclaimer: I am not in the "It's just the flu" camp. Respiratory diseases are serious. Anything that attacks your lungs are very serious. Pneumonia is not a joke. My mom almost died 3 years ago when she contracted Pneumonia, after undergoing a medical procedure. The day after her medical procedure, all of the sudden she started turning blue, essentially drowning due to fluids in her lungs. Luckily, she was still in the hospital at that point and they could resuscitate and intubate her. She was in ICU for nearly 3 weeks on a ventilator. It was one of the hardest times our family ever went through. A year later my uncle got Pneumonia from flu and died due to complications from the Pneumonia.

Hundreds of thousands of people have similar stories to this, however, we have never locked down entire nations, because of these tragedies. Getting Pneumonia from the flu is very real possibility. It will appear that we are in a very similar territory with the current pandemic. Not all people who get the flu will get Pneumonia and not all people who gets the new virus will get it either. There might be a higher chance with the new virus, but we'll need to wait for more widespread testing in order to draw conclusions.

Almost every single time that I felt sick enough to go to a doctor because of a cold, the flu or bronchitis, the doctors that treated me here in South Africa, gave me a doctor's note to take two days off work. I normally started to feel better by the time I went back to work, not particularly great, but able to work, nonetheless. However, I am pretty sure I was still able to spread my cooties around the office every single time. I would've liked to stay home for a week every time I got sick, to a) rest and feel better and b) not make my co-workers sick, but I also don't want to spend more money to go to doctor for a second time to get a new letter and I was not willing to dig into my leave days either. I am pretty sure this happens everywhere, but I don't know if this will hold up in the court of law.

Normally, nobody accuses you of trying to commit mass-murder when you go back to work, because the doctor only gave you two days off, but people are careful around you and you try to not cough and sneeze all over the place. Everyone in the office will automatically practice social distancing upon your return, because nobody wants to get whatever you had, nor would you like to give it to them.

Basic goods and restrictions

Banning "non-essential" goods is one of those things that I simply cannot wrap my brain around. I understand the need for social distancing, but who decides which goods are essential or which are not?

Consider the following:

Your kitchen appliances break, such as your fridge, freezer and or stove.

Your baby / toddler outgrew their winter clothes of last year.

Your work from home equipment suddenly stops working

You would like to start a work from home business and simply can't get your hands on the items you need.

As of the time of writing, you cannot replace or purchase any of these things as the shops are not allowed to sell you any of these items. If your means to prepare or preserve food no longer works, there is a good chance that you might go hungry. If your child does not have adequate warm clothes? What are you going to do? Is it okay for children to go through winter without being properly clothed? If your equipment breaks that allow you to work from home, there is a good chance that it might severely affect your income, or you might even lose your income altogether. Even further to that, if you lost your job when the lockdowns and the subsequent extensions started, you simply cannot get your hands on any items to start a new business from the safety of your home, because the items you require to do so are currently not deemed "essential".

Telling people what they can and cannot consume, especially if it was legal before is not a good framework for governance. Banning products such as alcohol and cigarettes have nothing to do with the health risks of these products. If it did, are baby clothes, electronic products, office equipment, and toys also unhealthy? Then why are these products banned from being sold? The lockdown rules imposed on us have nothing to do with health, but everything to do with government overreach. If government can dictate to you what you may or may not consume, what other rules can they also impose?

Let's ignore the stupidity of the currently banned items and consider the health argument for a second. If you consider that cigarettes and alcohol are bad for you and they should be banned, why not ban other products, such as donuts, chocolates and other refined food items? Those have some very severe health consequences when consumed in excess. If we go to the extreme end of this argument, and ban everything that is unsafe or unhealthy, we will have to ban almost everything. For example, cars kill more people than anything else in the world, so we should get rid of cars. You like skydiving? It's dangerous. Jogging? Cycling? You can get hit by a car (or bus if cars are banned). Someone once died of drinking too much water, I guess we should ban water too...

We can argue what people should or should not be allowed to put into their bodies, but enforcing that on a government level is absurd. You should be very scared of what it means for government to reach so far into your personal life.

Providing for your family

In South Africa our current lockdown duration is now set at 5 weeks. However, consider the lockdown being extended for 3 more months. Millions of people will lose jobs, their income, their means to provide for their family and subsequently be unable to put food on the table. As a nation South Africa does not have even close to the amount of money needed to provide food for even a third of the population.

If you are fortunate enough to work in one of those "essential" businesses you might not be scared about losing your job, but you should be.

People need insurance most of the time, but if you must choose between your kids starving and car insurance, what are you going to choose? Or if you work in banking, a lot of your clientele made decisions based on a 3-week lockdown period that was initially imposed. I am sure that very few people considered the lockdown will be extended and took out loans out of desperation, so that they can survive the 3 week lockdown, not 5 weeks. They now have a problem. They have no way to pay back the loans that they took. The bank suffers losses due to people defaulting on their loans.

I have not read any statistics, but I am pretty sure that those with annuities, provident funds, savings products and other sorts of long-term financial products, are pulling those funds at an alarming rate. It makes no sense to save for retirement when you don't have food to eat now.

Furthermore, we have even more problems that are truly frightening. Our government-run health care facilities are quite fragile. Everyone that is fortunate enough to have the means to pay for private medical aid do so. I am not sure what is going to happen, but if you can no longer pay for private medical care, those government-run facilities might completely collapse.

At the end of the day, starving people are not going to be able to eat insurance products, they are not going to care about retirement funds. There are much more pressing and immediate problems that need to be dealt with. Every single one of these "essential" businesses are going to suffer losses as well, and your job that you considered safe, is no longer looking so safe anymore.

The very idea that this lockdown is a sustainable "solution" is absurd. You are clearly living in fantasy land and think we can just print monopoly money, and everybody will be happy and spend the rest of their days in pajamas, watching Netflix and playing games.

There are very real consequences to these things.

My proposal

Social distancing. Social distancing. Social distancing. No lockdown. You are responsible for your loved ones. You need to ensure that you keep your loved ones fed, healthy, happy and safe. You will adopt your lifestyle to ensure that you can do these things in the safest way possible. Nobody wants to fail their loved ones and they will adopt to whatever circumstances are thrown at them. This is a natural phenomenon. It need not be imposed on people by force. If you go out in the world, sometimes bad things happen. You might die, but you will have made the decision that is right for you and the ones that you love. People inherently know what is best for their families, forcing people to fail their families, by not allowing them the opportunity to provide for them, is not helping them. You are imposing your will on them. This is called tyranny.

Of all tyrannies, a tyranny sincerely exercised for the good of its victims may be the most oppressive. It would be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end for they do so with the approval of their own conscience.

~ C. S. Lewis

Final Thoughts

We cannot live in fear of the unknown forever. We will be paralyzed, unable to function, unable to do what we are supposed to do. We need to press on, despite fear of the unknown. Death is part of life, there is no way getting around that.

I will leave you with yet another quote from C.S. Lewis:

In one way we think a great deal too much of the atomic bomb. “How are we to live in an atomic age?” I am tempted to reply: “Why, as you would have lived in the sixteenth century when the plague visited London almost every year, or as you would have lived in a Viking age when raiders from Scandinavia might land and cut your throat any night; or indeed, as you are already living in an age of cancer, an age of syphilis, an age of paralysis, an age of air raids, an age of railway accidents, an age of motor accidents.”

In other words, do not let us begin by exaggerating the novelty of our situation. Believe me, dear sir or madam, you and all whom you love were already sentenced to death before the atomic bomb was invented: and quite a high percentage of us were going to die in unpleasant ways. We had, indeed, one very great advantage over our ancestors—anesthetics; but we have that still. It is perfectly ridiculous to go about whimpering and drawing long faces because the scientists have added one more chance of painful and premature death to a world which already bristled with such chances and in which death itself was not a chance at all, but a certainty.

This is the first point to be made: and the first action to be taken is to pull ourselves together. If we are all going to be destroyed by an atomic bomb, let that bomb when it comes find us doing sensible and human things—praying, working, teaching, reading, listening to music, bathing the children, playing tennis, chatting to our friends over a pint and a game of darts—not huddled together like frightened sheep and thinking about bombs. They may break our bodies (a microbe can do that) but they need not dominate our minds.

In 1982, James Q. Wilson and George L. Kelling introduced a criminology theory called the Broken Windows Theory. The theory states that, by maintaining and monitoring urban environments that you could prevent small crimes - which eventually will lead to more serious crimes - from occurring. In the article titled

In 1982, James Q. Wilson and George L. Kelling introduced a criminology theory called the Broken Windows Theory. The theory states that, by maintaining and monitoring urban environments that you could prevent small crimes - which eventually will lead to more serious crimes - from occurring. In the article titled Broken Windows, released in the March 1982 edition of The Atlantic Monthly, they explained the following:

Consider a building with a few broken windows. If the windows are not repaired, the tendency is for vandals to break a few more windows. Eventually, they may even break into the building, and if it's unoccupied, perhaps become squatters or light fires inside.

and;

Or consider a pavement. Some litter accumulates. Soon, more litter accumulates. Eventually, people even start leaving bags of refuse from take-out restaurants there or even break into cars.

This theory forms the basis of my post, and it speaks to decay that occurs in software projects, as well as becoming stagnant in your career growth aspects as a Software Developer, and how your environment could potentially contribute to that.

For more information regarding the Broken Windows Theory you can go look at the Wikipedia article here.

AW&FUL Inc.

Most companies these days have a Software Development Department, and this department is often set up as a service department. That means that the Software Development Department is a valuable department within the organization, but it isn't a trusted advivor or a strategic partner to the business as a whole. The Software Development Department isn't as important as say, Marketing and Sales, and for a lot of companies it is only there to serve as a means to an end for the needs of the business.

Although this isn't necessarily the worst position you can find yourself in, there is something inherently wrong with this picture. The Software Development Department should be a strategic partner for the business. If you think of your Software Development Department as a service department, instead of a strategic business partner, you have a problem. In all likelihood your company will still make a profit, but you'll never be considered a good company to work for, you will not attract good talent for your Software Development team, you will always be under pressure when deployments are done, your business will not perform as stream lined as it could be and your companies profits might not grow as much year on year as before. We are moving into an age where you simply cannot be as relevant as you used to be, without making your Software Development Department a strategic partner.

For the sake of the article we'll refer to these companies that set up the Software Development Department in this way, as a single entity called: AW&FUL Inc.

Projects at AW&FUL Inc.

Often at AW&FUL Inc., you'll find that software projects are run poorly. The software might have a few broken windows, maybe even a bit of graffiti, but sometimes it is a full-blown invasion of meth/heroin addicted vagrants, and nobody knows when the building will collapse, or a fire will break out, and cause complete chaos. The real problem here is that the "chaos" I speak of, is anything from issues in production, to project being over time and over budget, and employee morale being low. Projects being over time and over budget is bad for the company financially, and normally the solution is to do a project death march when this inevitably happens, which is bad for morale to say the least, but the issues in production, for example the wrong account being debited/credited etc, can cause irreparable reputational damage.

Now this doesn't necessarily mean that you'll find these sorts of problems exclusively at AW&FUL Inc., but it seems to happen there more often. It also doesn't have to be a long running software project, it can be a brand spanking new project. It all boils down to software development processes and practices.

Companies love to assign strict budgets and fixed time-frames to projects, and who wouldn't? All of us like to know exactly how long something will take, and what it will cost. Be if for a home renovation project or fixing your car at your local service centre. However, these projects have a clearly defined scope and have historical data to support how long the renovation project should take, or how long it will take to fix your car, with software development projects this data is not readily available, or reliable.

The typical software development projects you encounter at AW&FUL Inc., are probably for a new product (or the revamp of an old project) that needs to integrate with a legacy system or ten. You have no idea how long it will take, where all the systems are that you need to integrate with, and not only that, you were most likely not involved in the planning phase of the project. Before you know it, you now have a project end date, and you don't even know what the project is. Obviously, this is not the ideal situation, but sometimes you suck it up, and do it anyway.

Our default fight-or-flight response in these situations is to take shortcuts, and hack the hell out of the software to get to that end date, but often we hurt ourselves in doing so, and we hurt the project we're working on. We are in fact starting to break windows.

More experienced developers do know how to fix broken windows, but they sometimes break them too. The problem is that the intent is always to go back and clean up, but time is not your friend. You often get assigned to a new project after the initial release, and all new features and maintenance gets assigned to someone else. Now the broken windows are part of the project, and you don't have any means to fix them. You can only hope that the person on the other end will find and fix the problems that you left, but this is often not the case. It does not really matter if the person is a junior, or a senior, they may simply not find it, or will simply not care.

As it is often the case, the developers assigned to these projects will settle for not caring. Before you know it, that 5 item switch case statement in the project is now 30 items long. Not a single variable name makes any sense. You have so many nested conditional statements that it would make inbreeding-hillbillies feel ashamed. You have classes that have a suffix of Helper or Utility or both, and there is always a file that is called Common; that is 3000 to 6000 lines long and will likely be the dumping ground of all the new features that are yet to be built. Now you have more than just a couple of broken windows...

I often think of the developers at AW&FUL Inc. as victims of their circumstances. When you first start working there, you are full of ambition, you want to build castles in the sky, you often fight to ensure things are being done "the right way", but as time progresses, you start to sympathize with your captors (see Stockholm syndrome) and you feel like you have no more energy left to fight the good fight.

Natural decline / devolution of a software developer

As time passes, the system becomes less and less well-ordered. Sooner or later the fixing cease to gain any ground. Each forward step is matched by a backward one. Although in principle usable forever, the system has worn out as a base for progress. ...A brand-new, from-the-ground-up redesign is necessary.

Systems program building is an entropy-decreasing process, hence inherently metastable. Program maintenance is an entropy-increasing process, and even its most skillful execution only delays the subsidence of the system into unfixable obsolescence.

After being a software developer at AW&FUL Inc. for a while, you've tried your best to do what you can to make things clean and maintainable, and everything seems to be a constant battle. At some point you stop caring. You don't stop caring about everything all at once. You stop caring about the little things, the tiny broken window in the corner.

At first, you stop caring about variable names, and namespaces and where things go. Then you stop caring about bigger things, such as keeping your methods and classes small and meaningful. You don't mind adding more and more if-statements and other conditional statements to that already 200-line method, because the building (software project) is already a bit dilapidated, and no-one will notice one more bad thing. You start copying and pasting things all over the place, instead of promoting re-use. You then start to copy things verbatim from the internet without knowing what the code does, or what the context of the code snippet was, it might just work out okay, but you're not sure, and you don't have time to look at it right now, the building is on fire...

It is up to you to realize that you have a problem. You only have two choices really. Are you going to start caring again about the work that you do, and rally the troops to drive change within your organization? Or will you decide that you have had enough of it, and you're tired, and that you should probably vote with your feet?

While you are still undecided on what to do next, it is your professional duty to keep your integrity intact and to grow your skills. You must still try to improve your environment and project, but you must begin with one broken window at a time, not the entire building all at once. Trying to make massive sweeping changes at this stage will only frustrate and demotivate you further. If you haven't been learning and keeping your skill set relevant, you need to ensure that you start immediately. You will need to get up to date with what has been happening in the industry and figure out what trends have been emerging, even if your knowledge is superficial, it can still be beneficial to just be aware of what problems certain technologies aim to solve, and why it has gained traction in the first place. The same advice applies when it comes to learning, start with one window, and fix your technology gaps gradually.

Conclusion

All software projects experience some entropy, and that is okay, but it's up to you to keep rot from setting it. Strive to build technology partnerships within your organization, and not master-slave relationships. Always keep improving yourself and your environment, one broken window at a time. If you find that you are feeling helpless and frustrated, you need to make time to do some introspection and evaluate yourself, and your environment critically and honestly.

I'll leave you to think about this quote from Frederick P. Brooks Jr.:

Years later, when I got to college, I learned about an important theory of psychology called Learned Helplessness, developed by Dr. Martin E. P. Seligman. This theory, backed up by years of research, is that a great deal of depression grows out of a feeling of helplessness: the feeling that you cannot control your environment.

Recently I've been dabbling a bit in the mobile development space. Ignorantly I tried to add an App.config to my Xamarin Android project, but there was no option available in the Add New Item dialog for it... Hmmm...?

Where on earth do I store configuration settings for your mobile application?

I was a little bit stumped, so I did what any self-respecting developer will do, and started googling. Here is some of the good suggestions that people had:

Use the #if preprocessor directive to build up your configuration settings.

Use a library called PCLAppConfig , that allows you to add App.config as an AndroidAsset and it will pretty much work like ConfigurationManager with a few additional setup steps.

There is a lot of options out there to try, but I wanted to try something else... How else will I make up content for my blog? I wanted to build something that is:

Build configuration specific,

Strongly typed,

Automatically updates on build, and;

Flexible

1. Build Configuration Specific - SlowCheetah

To make this solution build configuration specific, we are going to make use of transform files. This post explains transform files really well and I've included an extract from the post below.

A transform file is an XML file that specifies how the Web.config file should be changed when it is deployed

...

The purpose of these files is to generate a new Web.config file depending upon the environment. It's extremely useful to store settings in these files...

As you can see, this is very useful indeed. However, they are only mentioning Web.config files, what about other XML files? I've used SlowCheetah in the past to achieve this, and it is a fantastic tool!

It allows you to transform any XML-based file based on your build configuration. E.g. you can create a file called Bob.xml, right-click and choose to add transforms. For this to work from Visual Studio you need to install the extension and whenever you add a transform to an xml file it will add the appropriate build targets to your .csproj file and a NuGet package.

We'll start by adding a text file and renaming it to App.config, and add the following XML with single app setting for the BaseServerUrl:

SlowCheetah will transform the XML file and the resulting file will be copied to project's output directory. SlowCheetah will not update the source file, only the output file. I would like to do that. You can do this by adding a BeforeBuild target to the project file (.csproj):

2. Strongly typed - T4 Templates

I like T4 Templates. Microsoft seems to make good use of it, especially with Entity Framework (*.edmx), and on the Xamarin Android side with the Resources file. The Resources file updates on build, so, I thought I'd try and make it work for our scenario. Let's start by adding a new item to our project and searching for "text template", select the template, and call it CoreSettings.tt:

The T4 template basically creates a new C# file with the same name and reads the appSettings node from the App.config file. When you save the changes to CoreSettings.tt, CoreSettings.cs will update and now you have a strongly typed settings class:

/*
Auto-generated code, do not change. If you really need to change something, for example, you need to do this for Web.config, you
can change the template here: 'C:\Development\Personal\BarelyCompetent.XamarinSettings\src\BarelyCompetent.XamarinSettings.Core\CoreSettings.tt'.
*/
namespace BarelyCompetent.XamarinSettings.Core
{
public class CoreSettings
{
private static CoreSettings _current;
public static CoreSettings Current => _current ?? (_current = new CoreSettings());
public string BaseServerUrl => "http://dev.product/api";
}
}

I am by no means a T4 expert and the above code is probably not the best way of doing it, but it works for my scenario and you can edit it as you wish.

The T4 Template satisfies our second requirement: Strongly typed, but you must find and save the CoreSettings.tt file every time to get the latest update.

3. Automatically updates on build - Clarius.TransformOnBuild

I recently came across a library called Clarius.TransformOnBuild. The library consists of a MSBuild targets file, that will try to find the Transform.exe (this is what T4 files use in the background) file in the environment that you are building from. If it finds the executable, it will traverse your solution files for items with a Build Action of None that can be transformed.

To get this working you can add the NuGet package to your solution.

Install-Package Clarius.TransformOnBuild

And change the Build Action of CoreSettings.tt to None:

If you build your solution now, you will see that the CoreSettings.cs file will be updated. Clarius.TransformOnBuild satisfies our 3rd requirement: Automatically updates on build.

Finally, we can now use consume our CoreSettings.cs file:

CoreSettings.Current.BaseServerUrl

4. Flexible

In terms of flexibility the solution is simple, and you can extend it easily by changing the T4 Template, or adding additional setting files for different projects. This was written with Xamarin Android in mind, but you can apply the same principles for any .Net project.
Please let me know your thoughts in the comments section below.

When writing mobile applications, you'll inevitably consume some sort of REST service in your app and more than likely you'll be in charge of writing the REST service yourself. So how do you test your REST service integration on the mobile application while you are still developing it? Your device/emulator does not know how to connect to localhost:portnumber on your PC. You have a couple of things you could do in order to get this working.

Option 1 - Expose IIS Express application to your LAN

You can expose your IIS Express application to your LAN, using your current IP address, by adding a new binding to your IIS Express configuration, as explained in this post.

This is a good option, although it is little bit too manual for my liking. You probably don't want to permanently keep the new binding you created, and every single developer on your team that wants to debug an issue will have to setup the same thing on their development environment.

Option 2 - Emulators

Most emulators (e.g. see Genymotion Network Modes) have some sort of NAT or Bridged connection that you can use to connect to.

I don't particularly like this option. You can only test your REST service from an emulator. The NAT or Bridged connection is emulator specific and doesn't seem to be all that reliable and your IP address can change when updates are made to the emulator software. You can see for yourself in these StackOverflow links:

This option will allow you to test your REST service from the device, but you cannot step through the code if any issues arise, and you'll have to solely rely on your logs to get debug information. Not great if you are still developing your REST service.

Option 4: SharpProxy

As you can see from the description below SharpProxy is exactly what we need.

SharpProxy is a simple proxy server developed with the intent of being able to open up local ASP.NET development servers.

This allows you to test, hit breakpoints, and generally do development by using other machines and mobile devices.

Simply enter the local port number of your .NET development server and map it with an external port to host on.

**_From the github page of [SharpProxy](https://github.com/jocull/SharpProxy)_**

In the next part we'll get SharpProxy up and running. This will be a little bit of a manual process, because SharpProxy is really old, and you don't have a lot of places to just download the exe. Optionally I have created a Bitbucket repository with a zip file containing the SharpProxy.exe, that you can download and use.

Initial and final setup for SharpProxy

Let's clone the repository from Github to a folder that you can easily find. We'll just clone it to C:\Tools\SharpProxy.

git clone https://github.com/jocull/SharpProxy.git

Once the clone is complete, navigate to the directory that you just cloned and open SharpProxy.sln in Visual Studio. Run the application in Release mode. When the application launches, it will prompt you to allow access through your firewall. Choose the option(s) you feel most comfortable with and click on the Allow access button.

SharpProxy will try and determine your IP address and suggest an external port number for you to expose. In this case my IP address is 10.0.0.9 and it will open up port 5000. You don't have to choose port 5000, you can choose any available port you want.

You can now close the application and close Visual Studio. Open the solution folder in Windows Explorer and navigate to the bin/Release folder. Right-click on SharpProxy.exe and select Send To -> Desktop (create shortcut). You'll now have a shortcut on your desktop that you can easily access whenever you need to.

With SharpProxy now fully setup, we can dive into an example.

Project Setup

In my example project I have the following projects:

Xamarin Android Project

I only have one activity here in the Android project and it looks like this:

Hangfire is a really nice tool that allows you to perform background processing jobs in .NET. There are a bunch of different job types and it's all backed by persistent storage technologies such as MongoDB, SQL Server and a bunch of others.

By default, Hangfire works in a distributed fashion, in other words, all background jobs are serialized and persisted to your data store, and any server that is connected to that data store will be able to pick up the scheduled job and execute it. It is super easy to set this up and it works really, really well.

Hangfire Queues

Once you get the hang of Hangfire you'll inevitably want to schedule jobs that are specific to a certain server. The good news is that Hangfire has already made provision for that with queues. Any background job you want to exclusively run on a specific server can be decorated with a [Queue] attribute and explicit queue name. For example you can create a method called SendWelcomeEmail and decorate it with [Queue("emailonly")], and then configure your specific Hangfire server to only listen for jobs that are in the emailonly queue.

This is fantastic! The bad news is that if you want to send something to a queue at run-time, attributes are not going to help really...

Example problem

Say for example you are relying on the MemoryCache to build up some lookup items for your website and you would like to cache it on startup - out of process. Something like Hangfire will work quite nicely to achieve that. Since your server and client for Hangfire is in the same solution, you don't have to create a new service to do background processing, and you'll still have access to the MemoryCache.

As with the example above, MemoryCache is definitely server specific, and if you have the same code base in a web-farm with multiple servers, there is no way to actually control which server will process the background job without queues. But how exactly will you control it?

PS: I know a distributed caching solution will work better in this case, but please bear with me...

The Hangfire server setup will be really easy. You could get the queue name from AppSettings in Startup.cs or Global.asax when you setup your Hangfire server:

But the QueueAttribute is sealed, and there is no way to inherit from a sealed class. I had a look at the source code for the QueueAttribute on Github and found that the QueueAttribute inherits from JobFilterAttribute and implements IElectStateFilter.

I dug a little bit deeper and found out that Hangfire only cares about IElectStateFilter and JobFilterAttribute. This means we can create an attribute that looks like this: