Make your project up to date

27
MAKE YOUR PROJECT UP TO DATE BY SERGEY SELETSKY

Transcript of Make your project up to date

Page 1: Make your project up to date

MAKEYOUR PROJECT

UP TO DATE

BY SERGEY SELETSKY

Page 2: Make your project up to date

Agenda

Why are we afraid changes?

Why do we need changes?

Why is it is bad for us?

How to improve it now?

Which tool is better?

Best practices

Page 3: Make your project up to date

XobotOS

https://github.com/xamarin/XobotOS/

They just rewrite Android in C#

Page 4: Make your project up to date

You can revert everything

//Don't care about it, you have a GIT

Page 5: Make your project up to date

WHY?

5

Page 6: Make your project up to date

Common issues

Legacy Framework Library Language Tool

Design SOLID GRASP Anti-patterns

Page 7: Make your project up to date

Common issues

System impact: Performance Testebility Extensibility Predictability Supportability

Page 8: Make your project up to date

Supportability

Support $ are infinity in long term!

Total $ = (dev $ * dev time) + (support $ * life time)

540К$ = (10К$ * 6) + (4K$ * 120)360К$ = (40К$ * 6) + (1K$ * 120)

Economy: 180K$

Page 9: Make your project up to date

Why it is bad for us?

Long term project Higher costs Bigger team More work

Page 10: Make your project up to date

Why it is bad for us?

Long term project (everybody tired) Higher costs (lower per person) Bigger team (staff turnover) More work (more complexity) Unsatisfied customer No motivation Legacy knowledge More bugs & issues

Page 11: Make your project up to date

HOW?

11

Page 12: Make your project up to date

Use latest

• Choose architecture for the future• Always think about support• Cover everything with tests• Automate everything• Always use the latest tools and frameworks• Use own independent interfaces and APIs• Use NuGets

Page 13: Make your project up to date

Legacy projects

What to do?

Page 14: Make your project up to date

Cover code with tests

Cover everything before…

Page 15: Make your project up to date

Smart Tests

Cover everything before…

Page 16: Make your project up to date

My method for migration

1. Describe all scenarios for successful migration2. Identify patterns3. Create automated tools for migration4. Run tests, identify issues and repeat5. Correct manually a few complex issues that remain6. Do not forget to remove legacy code!

Page 17: Make your project up to date

Which tools better?

Better tool – simpler tool Transformation templates – for simple changes Generation templates – for similar code Regular Expressions – for everything T4 – used for own project templates Roslyn – advanced scenarios

Page 18: Make your project up to date

Regular Expressions

f = Regex.Replace(f, @"([a-z]*)\\s+function\\s+(\\w*)\\s*\\Q(\\E\\s*([^)]*)\\s*\\Q)\\E(\\s*\\{)", "$1 $2(%#$3%#)$4");f = Regex.Replace(f, @"([a-z]*)\\s+function\\s+(\\w*)\\s*\\Q(\\E\\s*([^)]*)\\s*\\Q)\\E\\s*:\\s*(\\w*)", "$1 $4 $2(%#$3%#)");f = Regex.Replace(f, "%#\\s*%#", "");for (int i = 0; i < 9; i++){ f = Regex.Replace(f, "%#\\s*(\\w*)\\s*:\\s*(\\w*)\\s*,", "$2 $1,%#"); f = Regex.Replace(f, "%#\\s*(\\w*)\\s*:\\s*(\\w*)\\s*%#", "$2 $1"); f = Regex.Replace(f, "%#\\s*(\\w*)\\s*:\\s*(\\w*)\\s*=\\s*([^):,]*)\\s*,", "$2 $1=$3,%#"); f = Regex.Replace(f, "%#\\s*(\\w*)\\s*:\\s*(\\w*)\\s*=\\s*([^):,]*)\\s*%#", "$2 $1=$3");}f = Regex.Replace(f, "(\\w+)\\s+as\\s+(\\w+)", "($2)$1");f = Regex.Replace(f, @"int\\s*\\Q(\\E([^)]+)\\Q)\\E", "((int)$1)");f = Regex.Replace(f, @"public var (.*?)\:(.*?)( \= )??(.*?)??\;", "public $4 $1 $3$2;");

Page 19: Make your project up to date

Regular Expressions

Before After

Page 20: Make your project up to date

Latest case

More than 200 Spring.NET objects

<object id=“Company.Web.GUI.WebServices.ContactsService" singleton="false" type="Company.Web.GUI.WebServices.ContactsService, Company.Web.GUI"> <property name="ContactInformationService" ref="ContactInformationService" /> </object> <object id="Company.Web.GUI.WebServices.PrivilegesService" singleton="false" type="Company.Web.GUI.WebServices.PrivilegesService, Company.Web.GUI"> <property name="LoginService" ref="LoginService"/> </object> <object id="Company.Web.GUI.SearchService" singleton="false" type="Company.Web.GUI.SearchService, Company.Web.GUI"> <property name="SearchUIService" ref="SearchUIService" /> </object>

Page 21: Make your project up to date

Latest case

Now it looks like this with Simple Injector

container.Register<IContactsService, ContactsService>(lifestyle);container.Register<IPrivilegesService, PrivilegesService>(lifestyle);container.Register<IContactsService, ContactsService>(lifestyle);

Also performance was improved in ~10-30 times

Page 22: Make your project up to date

Best practices

Use SonarQube for gated builds• Keep code as clean as posible• Code convention with zero compromises• Validate design and complexity• Improve software quality• Reduce technical risks

Page 23: Make your project up to date

Best practices

Use AOP and PostSharp• Keep code as clean as posible• Separate all cross-cutting aspects• Fail build when aspects missed• Optimize cross-cutting code

Page 24: Make your project up to date

Best practices

Use IoC Interception• Flexible decoration• Clean design and code• Better extensibility

Page 25: Make your project up to date

Best practices

Use TDD and DDD• Everything well tested• Everybody knows project• Monster project can be divided• Better UX• Better value from BA

Page 27: Make your project up to date

THANK YOU

27

Sergey Seletsky

[email protected]://www.linkedin.com/in/sergeyseletsky