Atlantic Business Technologies, Inc.

Author: Jeremy Wiggins

  • How to Hire the Right Developer

    Your deadline is coming up and your new app build is behind schedule. And as your blood pressure rises, you get an email from your boss. It’s a request for a new feature to amaze all your users ”or there will be a problem.” The good news? Your budget allows you to bring on a new developer to help with the overload. All you need to do is find, interview, and hire the right developer and your project will be back on track.
    Unfortunately, finding the right developer is never a simple task. There is an avalanche of things to consider before you can even begin looking for a candidate. What skills does the project require? Are there specific time constraints? What team dynamic do you want to build? After answering these questions, you need to have your recruiting and interview process prepared. Finally, you find the right candidate! But your job isn’t finished yet. You need to have your onboarding plan in place to integrate this new developer into your team. Then, they can begin to contribute as fast as possible.

    If this sounds like a complex task, it’s because it is. But don’t panic. This post will walk you through some guidelines to identify your specific needs, find the right candidate, and integrate them into your team smoothly.

    How to Identify Your Developer Needs

    The first step to staffing up for a custom software project is determining what kind of developer help you actually need. To figure this out, you need to ask yourself two kinds of questions: questions of timing, and questions of ability.

    Questions of Timing

    1. How soon do you need this developer’s help? Immediately, within the month, or sometime next quarter?
    2. How well can you predict what this developer’s workload will be? This is especially important if you have an immediate coding need but aren’t as sure about next steps like deployment or support.
    3. Do you want this developer to help with one particular project, or a series of similar projects over a longer period?
    4. If you’re filling a specific need for one project, what is your plan to utilize this developer so they don’t sit idle once they have finished their work on that assignment?

    Questions of Ability

    1. How specialized is the coding framework or technology you’re using?
    2. Do you want a developer skilled in one particular language or framework, or do they need to be able to handle multiple frameworks? What about separate technical tasks like tuning AWS environments or running QA tests?
    3. Are you sure you only need one new developer? Is it going to be easy to find the person you need, or are you looking for a highly-skilled unicorn?
    4. Would it be helpful for your developer to have other skills besides coding ability, such as an eye for visual design or a communications/writing background?

    Once you answer these questions, it’s also worthwhile to ask yourself more practical questions about your budget and team dynamics:

    Questions of Budget and Team Dynamics

    1. How much can you afford to spend hiring someone to fill your web development need?
    2. Do you have budget for a short-term candidate, or for a longer term commitment that may include salary and benefits costs?
    3. How flexible is your team with adding a new developer? Do you have the necessary desk space, hardware, and other overhead set up for this new role?
    4. Does the new developer need to work in the same room as your existing team? Do you have a remote access system in place with appropriate database access and a VPN?
    5. Who on your team needs to be involved with the hiring decision for your new developer?

    By answering these questions, you have your ideal developer in mind based on skill set, time commitment, available compensation, and how this person will fit into your team.  

    How to Find The Right Developer

    Woman at laptop in front of white board
    Recruiting the right developer is largely a marketing problem—you need the title and hiring language to persuade the best candidates to apply.

    Now that you can picture your perfect candidate, you begin what’s likely the toughest part of the process: hiring the right person. This stage involves two main steps: searching for quality candidates, and ensuring these candidates are right for your needs.

    Search for Quality Developer Candidates

    This might not seem obvious, but “How do I recruit quality developers?” is actually a marketing question. You need to grab the attention of your audience with the job title they’re searching for. You need to excite the audience to apply with the right details and description of what they will be working on. And you need to target the right audience to keep your search productive. You don’t want to waste time sorting through hundreds of resumes by unqualified applicants.
    Some projects only need additional developer help for a short time. If that’s the case, it’s best to engage a contractor on Upwork. You can also work with a technology consultancy (like us, here at ABT). Going in this direction narrows down the playing field. You can search for a provider who has the skill set you need and the flexibility to get started immediately. In fact, the only thing you’ll need to worry about is how to best communicate the nature and duration of the project. Your new partner will handle the rest.
    For long-term hires, you’ll be best served by a recruiter. They’ll be more adept at matching you with good candidates. The average job posting on Indeed or LinkedIn won’t be as concise. A recruiter will do the work of sorting through resumes and LinkedIn profiles for you. They’ll verify that candidates have the right skills and are a good fit for your organization. Hiring a recruiter will cost you (usually 15% of the developer’s first year salary). But, you will avoid the agony of going through hundreds of resumes in search of candidates that could be The One. You WILL have lots of unqualified people apply, no matter what your job description says. So, it’s easier to let a dedicated recruiter handle this part of the hiring process, if you have the budget for it.

    Verify Developer Candidates’ Skills

    So now you have a list of quality candidates. How do you make sure they actually have the skills they say they have? You can follow this step-by-step guide to hire software developers for more detail on sorting through cover letters.

    The next step in your screening process should be a simple phone interview with any promising candidate. By asking them to describe their career and expertise in their own words, you can often perceive whether they sound confident and capable (or if they’re making it up as they go, trying to sound smart). This conversation is also a good chance to verify your candidate wants to work on the kinds of projects you need them for, which helps ensure a good fit.

    If the phone screen goes well, the next step is having the candidate in for an interview. During this interview, it is not that important to quiz the candidate on how well they can answer technical questions. What matters more is having a candidate walk through his/her process so you can see how they solve problems, work with others, and fix mistakes. Can they talk intelligently about the architecture of a project they worked on? What design patterns did they use, and why? If they used 3rd party services or APIs, how did they integrate with them? Did they architect the application in a way that would allow it to fail gracefully if the service or API was down? One illuminating question can lead right into another.

    Turn Words Into Actions

    A classic way to have a candidate answer these questions is a white board test. Here you have your candidate model (draw) out a hypothetical problem or project: how his/her project would work, what tables they would have, what functions they would use, etc. Rather than writing code on the board, you’re asking them to visually depict how they would solve a lengthy programming problem. They are also free to talk through their ideas as they draw to fill in details verbally.

    guy at white board diagraming problem
    Use a white board test to see how your developer candidate talks through their process.

    It might be tempting to give your candidate a take-home coding assignment, but this can take way too long and in the meantime they might get an offer from another company that doesn’t require such a test. In-house tests solve this problem, but they’re high pressure and (because they usually demand multiple hours during a workday) also demand a lot from your candidate. You want to show respect for a candidate’s time, and the white board test should solve this problem enough.

    How to Hire the Right Developer

    Now you’ve found your ideal candidate and verified they have the skills you need. It’s time to close the deal by ensuring they are the right fit for your company and processes in a team interview. The “right fit” here is less about technical skill (since you verified that in the previous stage) than ensuring this candidate’s personality, work style, and goals line up with your company.

    Two developers collaborating over laptops
    Once you know your developer has the skills you need, make sure they know how to work well with others.

    Make Sure the Candidate Fits You

    How to gauge a candidate’s personality and work style is completely up to you. Some teams prefer outgoing communicators. They need someone who loves to talk out development with their colleagues. Others prefer more introverted developers. They respect a colleague who will try to tackle problems themselves, first. Some companies are fine with night owl developers who get to work at 10:30am and leave at 7:30pm. Some need their entire team at their desks at the same time. When it comes to these preferences, there is only one thing that matters most. You must communicate to your candidate what you expect of them. Then both parties can begin the new partnership with the same understanding.
    Then there are character issues, which are much more important. Outgoing or quiet, you want developers who communicate effectively and respectfully with colleagues. Not every developer will be a natural empath who can talk out conflict perfectly, but pay attention to how a developer responds to criticism or disagreement in your interview (Be sure to ask about how they handled conflict in the past!). In short, character rule #1 should be “Don’t be a jerk.”
    This may seem like it should go without saying, but we can’t emphasize it enough. How a developer solves problems is an integral part of his/her contribution to the team. Avoid hiring someone who is stubborn or inflexible when it comes to problem solving. The strongest team members are the one who can learn from mistakes. They listen and are willing to try different techniques. After all, programming is not a static career—if they’re not learning, their skills are going to get stagnant.

    Make Sure You Fit the Candidate

    Finally, ensure in the interview your candidate’s goals and career ambitions line up with your company’s immediate and long-term needs. If you need someone to lead development using a particular coding framework for multiple projects, you won’t want to hire someone who isn’t passionate about using that framework (even if they can use it with skill). Why? Eventually they’ll get bored with repeated projects using their less-favorite framework and look for a new job—or worse, phone in their work in that framework so the quality of your project suffers.

    The right connection between your developer’s goals and yours will be evident if they want to continue to grow their career in ways that align with your company’s larger mission. For example, a developer passionate about teaching and documenting their knowledge could eventually fit well in a management position. Someone who wants to learn more about Amazon Web Services or other cloud environments will be able to collaborate with your cloud engineers during deployment of the developer’s code.

    Hiring the Right Developer: Not Easy, But Worth It

    In case it’s not already obvious, hiring the right developer is a lot of work; you have to identify your specific needs, find the right candidate, then integrate them into your team smoothly. While this isn’t a simple process, there is nothing like the energy that a motivated and talented new developer can bring to your team. The result is not only a coding project finished on time, but an exciting new addition to your company who will make a lasting impact.

  • The Myth of the Full-Stack Unicorn Developer

    Recently, one of our long-term clients asked me to review a job posting they were struggling to fill. The client wanted a senior software application engineer. But not just any senior software application engineer. A “true full-stack developer” experienced in back-end development, front-end development, and architecting cloud environments and web infrastructure.

    Before the client asked my thoughts on this potential hire’s compensation package or how to find them, he led with the most important question: “Are we looking for a unicorn?” Unfortunately for our client, I answered yes.

    The Problem with Unicorns

    For developers, the word “unicorn” refers to someone with such a diverse range of skills that they’re incredibly rare. For example, an expert programmer who is also an ace visual designer. While such a person may be out there somewhere, they will be so hard to hire that they might as well be imaginary.  

    [general_cta subtitle=”Full-Stack Application Solutions” title=”Learn more about our client success stories.” button_text=”View Our Work” url=”/our-work/” type=”button button–primary”]

    Here’s how a successful unicorn hunt would go. First, you have to find them and make sure that the skills they mentioned on their LinkedIn profile are more than just words. Second, you’d need to hire them away from wherever they were currently working. Unicorns are rare, so companies will work hard to keep them. Third, you need to be willing to pay the high salaries these experts can demand. The result is a long time spent on a hiring process to acquire one person at a very high price. This is assuming he or she is exactly what you need, will fit in with your team, and won’t be headhunted away at a critical time in your project.

    In our client’s case, it’s not that it’s impossible to hire someone who knows back-end development, front-end development, and cloud environments. It’s just practically impossible to hire someone who is good at all these things. The challenge is that historically in our industry, these roles have been very segmented.   

    A Short History of Web Development

    How did this segmentation happen? The answer requires a little walk through web development history.

    The front-end of a website is comprised of HTML, CSS, and JavaScript. All three have matured over the decades. But JavaScript in particular has seen a recent explosion of libraries and frameworks built on top of it. These technologies have introduced back-end programming concepts to the language that cause the work between front- and back-end development to overlap.

    web development frameworks enable full-stack unicorns
    Web development today offers a lot of frameworks. This makes it easier to imagine a full-stack developer who can do everything.

    For example, languages like TypeScript have introduced class-based object-oriented programming fundamentals to JavaScript. This makes JavaScript feel more like a back-end language. Frameworks like AngularJS, Backbone.js, etc. have introduced MVC and similar patterns into JavaScript. And technologies like Node.js have introduced server-side JavaScript.

    The result is a traditional front-end developer now having skills and knowledge relevant to back-end programming. And conversely, a strong back-end developer will find some familiar concepts in current JavaScript libraries and frameworks. These multi-disciplinary programmers often refer to themselves as full-stack developers.

    Why Finding a Good Full-Stack Developer Is Hard

    So if these two divergent worlds are now more similar, then why is it difficult to find a “full stack” developer? There are two reasons. First, development is a constantly evolving and expanding field that makes dual mastery really tough. Secondly, that the “stack” now includes more than just front- and back-end programming.

    Deceptive Duality

    Despite the newfound overlap between back- and front-end programming, both sides of the spectrum are constantly evolving. In short, just because someone can do both doesn’t mean that they will be good at both. It also doesn’t mean that they will be able to stay current in both. With the recent explosion of JavaScript related languages, libraries, and frameworks, there is more to learn than ever. Keeping up with that while also staying current in back-end languages, libraries, and frameworks can be time-consuming and difficult.

    Too Many Hats to Wear

    The “stack” is more than just front- and back-end programming. Hosting infrastructure and cloud architecture is a different area altogether. A true full-stack developer also needs to know another set of programming in order to architect a cloud environment to host new applications. Essentially,  a network hosting engineer.  This means writing scripts to set up servers, ensuring the code is secure, and handling other aspects of deployment for every update. And don’t forget about QA. The full stack developer also needs to be able to design and run their own automated tests to ensure their code works well in the designated environment.

    In short, I told our client their job posting needed major revisions. Sure, they were likely to find applicants who consider themselves “full stack” developers. But their skills would severely lack in the hosting/infrastructure/cloud architecture department. Our client would also find people who say they have a background in both front and back end technologies, only to discover that they’re significantly more skilled in one because they’ve done it longer than the other.

    Why a Good Team Is Better than Hunting for Unicorns

    You can probably guess what I advised our client to do next—split this role into two separate positions. The first would be someone who knows back-end and front-end programming. They would also ideally know something about testing automation. The second would be someone who knows the hosting/infrastructure/cloud side.

    development team better than one full-stack unicorn
    A strong team of developers will always have advantages over one full-stack unicorn. Assuming you can even find one.

    This client’s big goal should be to foster a DevOps culture where these two people are working together, instead of hoping for one person to do everything. By relying on a smart team who knows how to share workloads and collaborate, our client would be able to tackle all the tasks they wanted this unicorn to do. They’d enjoy more flexibility in how they respond to changing project needs.

    Building a team also means you can hire and nurture true experts who are working on mastering the skills you need. Letting your programmers focus on the latest tools, frameworks, and techniques in their chosen field means they won’t dilute their skills by having to divide their attention across programming disciplines. This also protects your programmers from getting burnt out from extra pressure to perform completely different tasks on a project.

    If you’d like our input on how to find the right team for a development project, or if you’re looking for a partner to ramp up development resources, feel free to contact us anytime.

    [general_cta subtitle=”Ready to get started?” title=”Get in Touch for a Free Consultation” button_text=”Contact Us” url=”/contact/” type=”button button–primary”]

  • Tip: Choose which browser to debug with in Visual Studio

    By default, Visual Studio uses Internet Explorer for debugging. If you’re looking for a way to change that, perhaps to harness the power of developer tools in Firefox or other browsers (or perhaps just because you don’t like IE), it’s pretty easy to do.

    1. Right-click your start-up project in Studio and click Browse With…
    2. Click Add
    3. Click the Browse button beside Program Name
    4. Select the browser you wish to use
    5. Click Ok
    6. Select the browser you just added and click Set as Default

    Here are the install locations of some of the more common browsers:

    • Firefox: C:Program FilesMozilla Firefox
    • Chrome: C:Documents and SettingsUserNameLocal SettingsApplication DataGoogleChromeApplication
    • Safari: C:Program FilesSafari
    • Opera: C:Program FilesOpera
    • IE: C:Program FilesInternet Explorer

    I find myself using Firefox the most, followed by Chrome. And as a best practice, don’t forget to test your projects in all browsers before putting them into production!

  • Database Performance Tuning, Part 1 – Keys and Data Types

    Database performance tuning is a pretty strong interest of mine, and I’ve been lucky enough to get to work on some really cool database-intensive projects in my time at Atlantic BT. I’ll be the first to admit that I’m still not an expert on the topic and probably won’t be for some time. But having said that, I’ve had to pick up on at least a few things to get by, and I’d like to share some of those over the course of my next few blog posts.

    Two Common, But Easily Correctable Problems

    Two of the most common problems I’ve seen in databases are a lack of primary and foreign key constraints and poorly typed data. These problems can and will lead to performance issues, and even worse, bad data. Luckily, these are also two of the easiest problems to correct.

    Keys

    Set Primary KeyIf you want to increase the performance of your database, then here’s a great starting point. Make sure that your tables have keys. EVERY table should have at least a primary key. But you shouldn’t stop there; you should also have foreign key constraints on many of your tables (keep in mind we call them “relational databases” for a reason – so create some relationships between the tables!). This has two benefits.

    The first is the preservation of data integrity. Consider a simple example for a moment – two tables, Members and Address. The Members table has 2 columns, Id and MemberName. The Address table has a MemberId column and all the expected fields for addresses. Let’s suppose there is an undetected bug in an application that updates or inserts to these tables. Now think about the application that would consume the data. What happens when two members have the same ID? What about when the MemberId in the Address table doesn’t correspond to an actual Id in the Members table?

    In software development, bugs are an unfortunate reality. Having strict key constraints in your database will add an additional degree of safety to your applications. In our example above, the Members table should have the Id column marked as a primary key and the Address table should have it’s MemberId column marked as a foreign key to the Member table’s Id field.

    The second benefit is increased performance. Foreign keys will help the optimizer establish relationships between tables and primary keys will auto-generate a clustered index on the table. I’ll touch on this in more detail later in this post as well as in my next post but these both offer gains in performance.

    Data Types

    Another common problem is poorly typed data. An extreme example of this is every column in a table being labeled as varchar(max) and allowing nulls, but lesser offenses can still cause problems. Pay attention to the type, max length, and nullability of your columns and make wise decisions in setting these properties. In general, your decisions should demonstrate simple logic – use varchar(2) instead of varchar(max) if you’re storing State abbreviations, use int instead of varchar if you’re storing a number, etc.

    An Example

    Both of these concepts are easy to demonstrate. If you have access to a testing environment, run the following script to create a couple of test tables.

    CREATE TABLE [dbo].[WidgetDescription]
    (
        [Id] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [ItemName] [varchar](255) COLLATE  SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [Description] varchar(255) COLLATE  SQL_Latin1_General_CP1_CI_AS NOT NULL
    )
    GO
    
    CREATE TABLE [dbo].[WidgetCount]
    (
        [Id] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [WidgetId] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [NumberProduced] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
    )
    
    DECLARE @i int
    SET @i = 0
    
    WHILE @i < 100000
    BEGIN
        INSERT INTO [WidgetDescription] (Id, ItemName, Description)
        VALUES (cast(@i as varchar), 'Widget' + cast(@i as varchar), 'Description of the Widget')
    
        INSERT INTO [WidgetCount] (Id, WidgetId, NumberProduced)
        VALUES (cast(@i as varchar), cast(@i as varchar), cast(@i as varchar))
    
        SET @i = @i + 1
    END

    We’ve created 2 (poorly designed) tables that contain information about widgets. Now let’s examine some simple queries. Note that I’m using STATISTICS TIME to monitor the run-time of the queries. To see this information, click the Messages tab in the output when the query is complete.

    SET STATISTICS TIME ON
    SELECT NumberProduced FROM WidgetCount WHERE WidgetId = 1
    SET STATISTICS TIME OFF
    
    SET STATISTICS TIME ON
    SELECT Description FROM WidgetDescription WHERE Id = 1
    SET STATISTICS TIME OFF

    My average run-time for the queries is in the 24 ms and 26 ms range, respectively.

    Run Time
    Run Time of our 2nd query before any optimizations

    Now let’s take some simple measures to improve the tables and see the difference it makes. First we’ll just make some simple data-type changes to the WidgetCount table. Our columns are meant to represent numbers, so they should all be of type int. For the WidgetDescription table, we’ll make similar data type changes and add a primary key. Make the Id column an int, set it to Identity with auto-increment, and make it a primary key. Shorten the ItemName column to only allow 25 characters and shorten the Description column to allow 100. (In a production environment, we would also set up a foreign key constraint between the WidgetId column of the WidgetCount table and the Id column of the WidgetDescription table, but this isn’t necessary for this example.)

    The same query after applying primary key and data type changes
    The same query after applying primary key and data type changes

    Now run the queries again, and you should see run-times averaging around 8 ms and 1 ms respectively. As you can see, changing the data types boosted performance, and adding a primary key additionally boosted performance. If a difference of a few milliseconds doesn’t seem like a big deal, try thinking of it this way. In the second query, making a few simple changes to our table resulted in a performance boost of 2500%. That is indeed a big deal. It might not be so noticeable when dealing with milliseconds, but when you bring a query that takes 10 seconds to run down to under 1, it will be.

    So how do we explain this boost? Two things. As for the data types, ints use less disc space for storage than varchars, and varchar(25) and varchar(100) use less than varchar(255). So there is simply less physical data to actually inspect and return. But the bigger difference is the primary key. Without the key, the optimizer can’t know that the values in the Id column are unique. So even though it finds a match after examining one row of data, it has to look at the other 99,999 to make sure there isn’t another match. However, once we add the key constraint, the optimizer knows it can stop looking after it finds a single match. The optimizer is doing a table scan (slow) in one instance and an index seek (fast) in the other. Again, I’ll cover this in more detail in my next post.

    To summarize, I’ve outlined two very easy rules to follow to ensure that your databases are well designed. You should also start to see some performance boosts as a result of enforcing these rules. In my next post, I’ll show you how to examine the optimizer’s execution plan to create indexes on your tables in order to further improve your database’s performance.

  • Updating a .NET Page in Real-Time Using jQuery and AJAX

    Here’s a problem I bet you’ve run into before. You have a long-running function on one of your .NET pages and you want to provide real-time feedback to the user while they’re waiting on the function to complete (by function, I mean a method or a set of methods in the code-behind). So you put a variable somewhere on your page and you update it as the function runs. Then you realize that the variable value won’t actually change on the front-end until the postback is complete, which in turn means that it will get updated only once and say “Finished.” Just in time to tell the user what they already know.

    To get around this conundrum, I present to you jquery and ajax, my two favorite web technologies ever. AJAX is a group of technologies that allows you to interact with the server from the client-side without affecting the behavior of the existing page. What this means is that you can post to a page without getting the associated postback from .NET (and subsequent page refresh). If that doesn’t sound important, trust me, it is. If we can post to a page without getting a postback, then we’re already pretty close to real-time updates. All we need to do now is use jQuery to update the DOM as we do posts. Sound complicated? It isn’t.

    Back to our example, suppose a user clicks a button and that button fires a postback and runs 3 methods in the code-behind, DoStep1(), DoStep2(), and DoStep3(). The first thing we need to do is simply move these methods to a new page. If your original page was called DoWork.aspx, then a good name for the new page would be DoWork_Ajax.aspx.

    Now, back on DoWork.aspx, you probably have an asp element on your page that you’d like to update as the functions progress. You can replace this with a standard HTML element. DoWork() is a javascript function that will update this element. It looks like this:

    function DoWork(step)
    {
        if (step == 1)
        {
            $("#update-msg").html("Starting Work");
        }
    
        if (step == 4)
        {
            $("#update-msg").html("Finished");
            return false;
        }        
    
        $("#update-msg").load(
            "DoWork_Ajax.aspx #results span", 
            { workStep: step }, 
            function(){ DoWork(step + 1); } 
        ); 
    }
    

    Assume that #update-message is a span on our page, i.e. a placeholder for the status of our worker functions.

    The logic flows as such: If we’re on step 1, tell the user we’re starting. If we make it past step 3, we’re done, so tell the user that too and return from this function. Finally, the meat of the function – Do an asyncronous post to DoWork_Ajax.aspx, telling it what step we’re on, and injecting a span from it into the DOM for the current page.

    The PageLoad method for DoWork_Ajax.aspx looks like this:

    switch (Request["workStep"])
    {
        case "1":
            DoStep1();
            break;
        case "2":
            DoStep2();
            break;
        case "3":
            DoStep3();
            break;
    }
    

    Each method updates an element on the page, just like before. This is the element that gets injected into the DOM by our jQuery function on DoWork.aspx.

    You’re doing the exact same work as before, but now you can update the page in real time. I’ve included a sample application that demonstrates everything I’ve talked about. For those that are interested, you can download the project and run it locally to see this in action.

  • Dynamic Body ID and Class properties on ASP.NET Master Pages

    Master pages are a great feature of ASP.NET. However, they do have some drawbacks, one being they do not easily offer the flexibility of dynamic body ids and classes that our design team here needs.

    Luckily a solution exists, and best of all it isn’t all that difficult to implement. The solution is built around the idea that child pages can access their master page, as well as any publicly exposed properties on the master. For example, in the Page_Load method of a child page, you can write:

    MyMasterPage masterPage = Master as MyMasterPage; masterPage.Property = “property value”;

    This is not ideal though, because we are now committed to never changing our child’s master page; if we do, it will break our build. The correct implementation of this concept is to create an interface that all of our master pages will implement, then use that in our child pages’ Page_Load method:

    IMasterPage masterPage = Master as IMasterPage; masterPage.Property = “property value”;

    We can still set our property this way, only now we can later change what master page we use, as long as the new one still implements the same interface. Good stuff. So good, that it puts us most of the way there towards dynamic body ids and classes.

    To get these, we need a couple of properties on our interface:

    public interface IMasterPage { String BodyId { get; set; } String BodyClass { get; set; } }

    Then, in the code-behind file for our actual master page:

    public partial class MasterPagesDefault : MasterPage, IMasterPage { private string _bodyId; private string _bodyClass; public string BodyId { get { return _bodyId; } set { _bodyId = value; } } public string BodyClass { get { return _bodyClass; } set { _bodyClass = value;} } }

    Finally, in the master page’s body tag:

    <body id=”<%= BodyId %>” class=”<%= BodyClass %>”>

    Now, to set these dynamically, use the child page’s Page_Load method just like before:

    IMasterPage masterPage = Master as IMasterPage; if (masterPage != null) { masterPage.BodyId = “index”; masterPage.BodyClass = “index two-col”; }

    By using publicly accessible properties, we give child pages the ability to set values on their master page. With this, it is easy to create dynamic body classes and ids in .NET.