Prepare your Angular1 to Angular2 migration

As a Sr. Software Architect, currently I’m working on very large Angular 1 project. We have over hundred controllers, services, directives and components. Our goal is to convert the project into Angular2 in order to use pre-rendering techniques. Unfortunately, we cannot stop current development and spend time to massive conversion.  We have many feature that we need to implement asap.

In order to simplify conversion we adopted several strategies:

  1. We converted our JavaScript files to Typescript. The compilation and types bring immediately code quality benefits. We discovered several bugs that we missed during development and testing.
  2. We are starting to use Angular 1.5 components for every new form.

Continue reading

Advertisements

Package Manager and update-database timeout

When you are using the Microsoft Visual Studio update-database command in Package Manager, you may receive the following error:

ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-1,State:0,Class:20
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

This error maybe because you have another project in solution with Entity Framework and a separate database deployment. If that (separate) project set as a “StartUp Project” that is most likely reason for timeout. Make sure that correct project is set as Default Project in Package Manager console and it also set as StartUp Project in Solution Explorer.

GE Centricity Loading issue fix

If you are using GE Centricity CPS 12 and experiencing client loading issue, try the following:

  1. Add your site to the IE browser compatibility view;
  2. Clear user setting by executing the following SQL statement (please replace the ‘username’ with actual user name):

DELETE from UI_LAYOUT where pvid= (select PVID from USR where LOGINNAME = ‘username’)

Create app.config transformation for vdproj deployment projects

To add transformation follow these steps:

  1. Create new App.Debug.config and App.Release.config transformation files and exclude them from project.
  2. Unload MyProject.csproj project from solution.
  3. Right mouse click on the project file and select Edit “MyProject.csproj”.
  4. Search for app.config string.
  5. Change to:
      <ItemGroup>
        <None Include="App.config">
          <TransformOnBuild>true</TransformOnBuild>
        </None>
        <None Include="App.Debug.config">
          <DependentUpon>App.config</DependentUpon>
          <IsTransformFile>True</IsTransformFile>
        </None>
        <None Include="App.Release.config">
          <DependentUpon>App.config</DependentUpon>
          <IsTransformFile>True</IsTransformFile>
        </None>
      </ItemGroup>
    
  6. Add after above code:
      <ItemGroup>
        <Content Include="$(OutputPath)$(AssemblyName).exe.config">
          <InProject>false</InProject>
          <Link>$(AssemblyName).exe.config</Link>
        </Content>
      </ItemGroup>
    
  7. Add the following code just before the </Project> tag:
      <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
      <Target Name="AfterCompile" Condition="exists('App.$(Configuration).config')">
        <!-- Generate transformed app config in the intermediate directory -->
        <TransformXml Source="App.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="App.$(Configuration).config" />
        <!-- Force build process to use the transformed configuration file from now on. -->
        <ItemGroup>
          <AppConfigWithTargetPath Remove="app.config" />
          <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
            <TargetPath>$(TargetFileName).config</TargetPath>
          </AppConfigWithTargetPath>
        </ItemGroup>
        <PropertyGroup>
          <SetupProjectPath>$(MSBuildProjectDirectory)\$(IntermediateOutputPath)$(TargetFileName).config</SetupProjectPath>
        </PropertyGroup>
      </Target>
    
  8. Save and reload MyProject.csproj
  9. Go to Setup (.vdproj) project and add MyProject.csproj as Primary Output.
  10. Select added project and add ExcludeFilter *.config
  11. Add MyProject.csproj as Content Files.
  12. Build solution. You will have correct transformed configuration file in your setup project.

Entity Framework 4.1 and Unit Test of your Data Access Layer

Several years ago I wrote six articles about unit testing with Microsoft Entity Framework 4.0. The Entity Framework (EF) went through several iterations. In this articles I will review version 4.1 as it compatible with .NET framework 4.0.

The new DbSet object was introduced with version 4.1, significantly improves unit testing process. I used a factory pattern to create entity container object. The DBContextFactory class implements IDBContextFactory interface below:


public interface IDBContextFactory<out T> where T : IDisposable
{
T Create();
}

Note the “out” keyword in front of “T”. The “out” parameter allows to use an interface instead of solid class.

Implementation of DBContextFactory is below:

public class DBContextFactory : IDBContextFactory
{
public MyEntities Create()  {  return new MyEntities();  }
}

I typically add another copy of DataModel.Context.tt called: DataModel.IContext.tt and modify it to generate an entity interface class: IMyEntities.

The IMyEntities interface implements all entities such as:

IDbSet Users { get; set; }

I also adjust DataModel.Context.tt to a) implement IMyEntities interface; b) correctly implement IDisposable interface.

With all above my repository is changed to use factory:

public class Repository : IDisposable
{
IDBContextFactory _factory;
IMyEntities _context;
public Repository(IDBContextFactory factory) { _factory = factory; _context = _factory.Create(); }

public User GetUserById(string id)
{
var user = _context.Users.Where(e => e.UserId == id).FirstOrDefault();

return user;
}

#region Implement IDisposable

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

~Repository()
{
// Finalizer calls Dispose(false)
Dispose(false);
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// free managed resources
if (_context != null)
{
_context.Dispose();
_context = null;
}
}
}
#endregion

}

Here is my RepositoryTest class:

[TestClass()]
public class RepositoryFixture
{

MockRepository Mock { get; set; }
IDBContextFactory MockFactory { get; set; }
IMyEntities MockContext { get; set; }

#region Additional test attributes

//Use TestInitialize to run code before running each test
[TestInitialize()]
public void MyTestInitialize()
{
Mock = new MockRepository();
MockFactory = Mock.DynamicMultiMock();
MockContext = Mock.DynamicMock();
}

//Use TestCleanup to run code after each test has run
[TestCleanup()]
public void MyTestCleanup()
{
Mock = null;
MockFactory = null;
MockContext = null;
}

#endregion

///
///A test for GetUserById
///

[TestMethod()]
public void GetUserByIdTest()
{

Expect.Call(MockFactory.Create()).Return(MockContext);

User user = new User { UserId = “1”, First = “Jo”, Last=”Do” };
List list = new List();
list.Add(user);

IQueryable qlist = list.AsQueryable();
IDbSet users = MockRepository.GenerateStub();

Expect.Call(MockContext.Users).Return(users);

users.Stub(a => a.Provider).Return(qlist.Provider);
users.Stub(a => a.Expression).Return(qlist.Expression).Repeat.Any();

Mock.ReplayAll();
// Repository r = new Repository(new DbContextFactory()); //CALL DB
Repository r = new Repository(MockFactory);
Assert.AreEqual(“Jo”, r.GetUserById(“1”).First);
Mock.VerifyAll();
}
}

Conclusion.

New DbSet object in EF 4.1 significantly improve unit test of the Data Access Layer.

Please feel free to contact me for any project where you would need to implement a simple DataAccess layer.

GE Centricity New HTML Forms

The new GE Centricity release 12 will introduce new HTML forms that allow users to build medical context using simple HTML and JavaScript. Researching GE solution, I discovered several interesting behaviors of proposed solution. I would like to mentioned that I used early beta and some of this ideas or features may not be accurate in the released product. The first that I noticed that HTML forms are using the ActiveX control. Actually, there are two ActiveX controls that are part of the same assembly.

  1. GE.CPO.EMR.80.MEL
  2. GE.CPO.EMR.90.Application

Instantiation of ActiveX control is quite simple:

<script>

var mel = new ActiveXObject(“GE.CPO.EMR.80.MEL”);

var patientFirstName = mel.eval(‘{PATIENT.FIRSTNAME}’);

</script>

The only downside is that these ActiveX controls must be instantiated inside the Centricity system. This way makes the HTML form design process a bit more complex. Developer should use the Centricity to validate any changes to HTML form.

The Centricity host an HTML form inside standard WebControl. This method has several pros and few cons. One of the pros: HTML is completely isolated from the outer Centricity forms. Developer has no access to the outer forms and cannot bring down or compromised system by introducing bug (or malicious code) in the form. But in order to use latest CSS you need to add few line of code to your HTML form. Also other cons is that HTML Forms are always cached by default. To open always a fresh copy of the HTML form the META directive need to be added to the HTML form.

The best of all that now you can use any HTML editing tools including Free Microsoft Visual Studio Express edition.

Few words about Renet Consulting, Inc. We have experts to assist you with your clinical context needs and especially with HTML forms for GE Centricity 12+. Contact me using form below.

Building Application with Remote Team

Many companies struggle with locating local right skills software developers. Working with remote team was not successful for many small and large companies. This article is outlining basic techniques to make advantage of the remote team management.

    Let start with basic challenges that is most stakeholders are fear:

  1. Code ownership;

  2. Telecommuter time spend on the project;

  3. Team collaboration.

    All this fear could be easily overcome by using standard techniques. Let start with “Code Ownership”. Project manager can set up a virtual PC with all necessary tools on it such as Visual Studio and licence development tools. Typical box is configured with 8G memory 2CPU and 100Gb disk drive. Developer will VPN to the box to get access to all local and network resources. As developer will coded on the company PC, project manager can be sure that

  • Code produces by developer is copyrighted.

  • Code is not copied to use for another project.

  • Minimum chance to introduce viruses into the system.

  • Project manager may also control time that developer spent on PC.

    The second fear: if developer worked time that he or she claimed on timecard. The scrum approach is the way to control this fear. Professional scrum master can easily control the task-to-time that remote developer spent working on the particular story. As scrum master and scrum professional I used several simple techniques to approximate amount of time that is necessary to  complete stories.

    Technique to help with team collaboration is

  • WebEx;

  • Google Chat;

  • TeamCity / CruiseControl

  • SVN / GitHub

  • FxCop/Gendarme

The next, I would like to outline Developer PC. My recommendation is to use Windows 7 Professional with Visual Studio Professional edition. Install FxCop as Code Analysis and NUnit as unit testing. Your choice of source control. I recommend to use SVN as it provide better source protection and majority developers are familiar with it usage.

The typical way for team collaboration is scrum way. Any project start with “planning” meeting. Do not assume that developers know what to do, just because that said so. You have to be absolutely sure they have clear understanding all tasks and stories. Make sure that all stories are broken down to the tasks that are not more than 0.5 day. If somthing take 40 hours just ask developer to break story to 1 day tasks. The 5 days story is an epic that should be broken to the smaller stories. something take too long means: developer do not understand story or  he/she confused on what to do. Any developer can under-estimate any task. Let take a simple example: you have one 5 days story and ten 0.5 day stories. Let assume developer underestimate a story and it will take 2 time longer.  You can see that you will have 80h project vs 40.5h project. If developer make mistake on EVERY task – change developer. In fact most developers will understand this and will try to catch up on other tasks.

Make sure you stated what is “DONE” is for every task. Make sure your done statement included unit test coverage. This is very important as it should part of developer estimation.

Control. Check daily progress of developer assignment. Daily standup should be short 3-5 min per developer. Do not try to solve any issue – just arrange another meeting after standup.

Make clear to developer that any issue that will delay task more than 1 hours must be reported to the scrum master.

Remote developers are minimized lost of productivity during break socializing, daily traffic frustration, office rental, electrical bill, parking leasing.

Stay away for oversea teams. Unless they are very inexpensive QA team. Keep one or two local (US) QA engineers. Do not expect oversea team do much. Same time the oversea team may bring more distractions than benefits. Again: keep developers and QAs in 3 hours time zone.

My final recommendation: do not be cheap. Good professional are expensive. If you negotiate 50% of developer regular rate, that mean you may lose developer on the middle of the project. This will cost you more than pay developer his /her regular rate. Try not to settle with junior developers as well. Professionals can finish tasks faster and with significantly better quality. Junior and Senior is not related to age, but to related professional field experience.

I have few recommendation about interview process. Asked candidate in limited time (typically 1 to 1.5 hour) develop a simple application with well knowing algorithm. For example: find max prime number in 1 min. In this task developer will a) show time management; b) research algorithm c) code quality; d) unit testing; e) coding standards.

Always check references from previous project/job. If someone said “sorry but we cannot provide any references” – sound is trouble. No one will reject to provide you good references.

Sometime in the team of senior developers maybe one or two who has a problem with authority.

Watch those troublemakers. If you cannot control them – replace them. Rule of thumb: play well or walk out.

Few words about myself. My name is Alexander Altotsky. I’m senior software architect in Renet Consulting, Inc. with over 20 years development and project management experience. I certified Scrum Master, certified Scrum Product Owner and Certified Scrum Professional. Feel free to contact me with your project request.