Category: dev thoughts

Intermezzo–options for loading multiple providers of data – part 10

We have 2 national banks –  and we gather exchange rates from there. What if we want to add more banks  -or let other programmers to add their dll’s to our software to just display the exchange rates from other banks ?

 

Option 1: HardCode all the list


var l = new List<IExchangeRates[]>
{
new GetFirstBank()),
new GetSecondBank()),

};

Option 2: Reading from some config file the list of classes – letting DevOps to modify the config file

var l = new List<IExchangeRates[]>;

foreach(var line in File.ReadAllLines(“myListOfExchangeRates.txt”){

IExchangeRates r= Activator.CreateInstance(Type.GetType(line)) as IExchangeRates ;

l.Add ( r );

}

Option 3: Reflection – in the current assembly or in all assemblies to load the classes that implements the interface to load the data

var typeToFound = typeof(IExchangeRates);
Assembly a = Assembly.GetExecutingAssembly();
var types = a.GetTypes()
.Where(it=>it.IsPublic)
.Where(it => it.GetInterface(typeToFound.FullName)!=null)
.ToArray();
foreach(var t in types)
{
recognizes.Add(Activator.CreateInstance(t)as  IExchangeRates);
}

Option4 Load as plugins

use the library from  https://github.com/natemcmaster/DotNetCorePlugins/blob/master/samples/hello-world/HostApp/Program.cs  and there are 2 lines , basically:

var loader = new LoadExchangeProviders("plugins");
var exchange = loader.LoadExchangeProviders().ToArray();

And one hour passes...
(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )
NrPost 
1Start
2Reading NBR from internet
3Source control and build
4Badge and test
5CI and action
6Artifacts and dotnet try
7Docker with .NET Try
8ECB
9Intermezzo - Various implementations for programmers
10Intermezzo - similar code - options
11Plugin implementation
12GUI for console
13WebAPI
14Plugin in .NET Core 3
15Build and Versioning
16Add swagger
17Docker - first part
18Docker - second part
19Docker - build Azure
20Pipeline send to Docker Hub
21Play with Docker - online
22Run VSCode and Docker
23Deploy Azure
24VSCode see tests and powershell
25Code Coverage
26Database in Azure
27Sql In Memory or Azure
28Azure ConString, RSS
29Middleware for backward compatibility

Intermezzo–program based on experience–part 9

This post will be somewhat related to https://www.smart-jokes.org/programmer-evolution.html – but it makes total sense for me.

Let’s take what we achieved until now: We have 2 national banks –  and we gather exchange rates from there. What if we want to add more banks  -or let other programmers to add their dll’s to our software to just display the exchange rates from other banks ?

Let’s say now that the requirements are to to display the exchange rates for 2 national banks into a console program .  The manager says that later we may add other banks to load exchange rates . I will try to explain some differences how the code is created, depending on the experience.

Junior programmer: – all the code inside


int Main(){

// code for load and display the first bank exchange rates

// code for load and display the second bank exchange rates

}

Internship programmer: – create classes


//create  2 classes ( first bank, second bank ) and a Load method

int Main(){

var firstBank = new FirstBank();

var data = firstBank.Load();

DisplayData(data);

//same for second bank

}

Seasoned Programmer: – creates interfaces


//add to the 2 classes an interface , loading into a list, loading data for all the list, display

int Main(){

var l = new List<IExchangeRates[]>;
{
new GetFirstBank()),
new GetSecondBank()),

};

foreach(var rates in l){

var data= rates.Load();

DisplayData(data);

}

 

Until now, it is business as usual. But, from now on, there are many things that can be done , depending on programmer experience and will to do things ( until some error arrives and there is an official task for it) :

  1. How to handle errors ( Polly ? )
  2. How to load different libraries that contains our interface ( writing code that loads directly a list with all classes / DI / reflection / config files / plugin loader )
  3. Think about performance ( loading data in parallel / caching )
  4. Add Tests + code coverage
  5. CI / CD

( if I do miss something, please put on comments)

 

What is my point here ? Is that I expect any programmer to go very fast to the level of Seasoned Programmer. But , after that, the knowledge of each programmer is relevant about how he does the points above ( or, if he does not …)

And one hour passes...
(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )
NrPost 
1Start
2Reading NBR from internet
3Source control and build
4Badge and test
5CI and action
6Artifacts and dotnet try
7Docker with .NET Try
8ECB
9Intermezzo - Various implementations for programmers
10Intermezzo - similar code - options
11Plugin implementation
12GUI for console
13WebAPI
14Plugin in .NET Core 3
15Build and Versioning
16Add swagger
17Docker - first part
18Docker - second part
19Docker - build Azure
20Pipeline send to Docker Hub
21Play with Docker - online
22Run VSCode and Docker
23Deploy Azure
24VSCode see tests and powershell
25Code Coverage
26Database in Azure
27Sql In Memory or Azure
28Azure ConString, RSS
29Middleware for backward compatibility

My take on battles in IT

 

First battle : VBScript vs JavaScript. Both were scripting on the browser. VBScript loose because NetScape did not implement it.

Second battle: Microsoft vs Java. Starts with a Microsoft Java implementation  – then C# takes over.

Third battle: MVC vs Silvelight . MVC wons – Silvelight does not work against Chrome.

Fourth battle : Desktop vs Mobile+Web   –  Web wins by large ,  And with Electron  + Cordova , web wins back

Now there are

  1. WebAssembly vs Web. I bet on Web.
  2. Odata vs GraphQL . I bet on GraphQL . OData was too linked to EF ( although now can work without)
  3. DataScience: Python vs R . I hope to win either ML.NET, either JavaScript.

 

What are the battles that you observe ?

Sometimes it’s difficult

I am a good contributor(+moderator) at www.asp.net  forums ( and I love MVC ). Sometimes it’s very difficult to stay calm . Let’s make an example:

 

[new programmer first post]

Hi I am new in ASP.NET mvc 3

I want to insert/modify collection on the page without refresh.

[ code for database first]

Now on create product View I want to add a composite in IList<Composite> Composites collection.

 

 

[My answer]

2 things here:
Modify a collection in MVC : http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

Send via ajax : http://bit.ly/mvc_ajax_jquery

 

[new programmer answer after 4 ( FOUR!) minutes]

Hi ignatandrei

Thanks for the reply.

But I have no idea how to implement this thing.

can you give me a small example regarding this.

I have tried many times but not successed.

 

[My answer]

quoting “I have no idea how to implement this thing” from new programmer

What thing of the 2 I have shown you ?
More, I admire your fast reading if you read 2 tutorials(max 6  minutes)  so fast , download codes , reproduce and decide that you do not understand.

 

[new programmer]

Hello ignatandrei

I am sorry… The links which you have posted was not underlined/highlighted; so that’s why I thought  it were like suggentions. because of that misunderstanding I replied you back for demo application.

 

 

And then the usual combination of “ I am getting an error” – although my tutorial it handles errors – both from server side and communication side

However, when someone asks for help it is good to READ what other said – even it was suggestions…

And , as I say, sometimes it is difficult to stay calm. What have you answered?

This software is free

image

 

This is an MVC add-on to add a messaging system to any MVC application. It costs me 0$ to make this program ( not yet finished, but free source at http://messagemvc.codeplex.com/  and the related posts are at http://msprogrammer.serviciipeweb.ro/category/howto/asp-net-mvc/mvc-4/mvc-messaging-system-mvc-4-asp-net-mvc-howto/ )

Home Computer – already done for browsing the internet.

Download Visual Studio Express – free .

Download Sql Server Express – free.

Download latest bits of EF 4.2 – to work with SqlServer Compact too – free.

(Connection to internet : 25 $ – but was already done for browsing the internet)

Installing and configuring software on my PC – 0 $.

All I have done is to sit on my home desk and tapping into the keyboard. But this is does not costs , right?

Making, Planning, testing, deploying – 0$.

[quote from=http://www.petapixel.com/2012/01/10/this-photograph-is-not-free/ ]

So if you’re a magazine, website, corporation, sports team, or advertiser developer who wishes to use this photo  software , please don’t   come and ask to use it for free, or in exchange for credit or “exposure”.

[/quote]

Do not give feedback . Just rant about how bad code smells ,about how OOP and SOLID and Design Patterns are not made clear and how Testing is not properly handled. After all, it is free , right?

Sql developer versus C#(.NET ) developer

I am not very well yet from my operation – so I can not write yet a tutorial.

But I want to propose you the following difference: Sql developer versus C# developer.

In my opinion , nowadays, if you program some application , you MUST have some database. More, the retrieving of data from the dtabase is a matter of relative speed to be seen by the user. So , for me, every .NET programmer should know about indexes / schema / foreign keys / users and so on. More, it has to know about connection pooling and stored procedures.

So, in my opinion ,  you can not be a .NET programmer without knowing much about databases.

What do you think, dear reader?

( This post is generated from a discussion in that the guy says that “I’m a C# developer, not a SQL developer.” and then leaving hints like “Any organization that follows a business practice of SQL users on databases needs to fire their DBA and find someone with the knowledge and foresight of how to scale security in db roles and filter the access through the domain admins (i.e., adding users to a user group in AD).”  and then “was the primary DBA for a number of years covering SQL7-SQL 2005. “)

What do you think about the discussion ?  And about the sql developer versus .net developer?

Javascript hell

In 1997-200x days, when I have been programming in VB3-6 , there was a problem named ”DLL Hell”.

I have been hoping that, with the introduction of .NET, we will escaping this – and I have had my request answered( ok, from .NET 2 )

However, a new problem is for WebDevelopers : JavaScript Hell. Why I am telling that ? Simple :

  1. I have an application that works well in IE 8Star – and uses Json.Stringify to post data. Normally, when I was trying with IE7, it does not work – because JSON.Stringify was not allowed …Of course , solution was adding javascript from http://www.json.org/js.html .
  2. Same application use jquery 1.4 + http://knockoutjs.com/ 1.1.2 (to can modify dynamically some textboxes) + other js( a date time formatter,jquery ui and others)- . Now , in IE9 RC , jquery1.4 does  not function – and you have to use jquery1.5.1.rc also.Please tell me how to know what modifications the other js files must have( in particular knockout) .

And the mock idea is not solving the issue. You must test either manually , either with an automated test for browser(like Selenium) and testing explicitely in browser version! And I have  speak only about IE, not Firefox and /or Chrome…

If you are a developer, how many javascript do you use? If more than 2 ,welcome to javascript hell!

Star : Please read the requirements from http://msdn.microsoft.com/en-us/library/cc836459%28v=vs.85%29.aspx :

Note:

Starting with JScript 5.8, by default, the JScript scripting engine supports the language feature set as it existed in version 5.7. This is to maintain compatibility with the earlier versions of the engine. To use the complete language feature set of version 5.8, the Windows Script interface host has to invoke IActiveScriptProperty::SetProperty.

Internet Explorer 8 opts into the JScript 5.8 language features when the document mode for Internet Explorer 8 is “Internet Explorer 8 Standards” mode. For other document modes, Internet Explorer uses the version 5.7 feature set.

JScript 5.8 includes native JavaScript Object Notation (JSON) support and the accessor methods for Document Object Model (DOM) prototypes.

Programmer retrospective – 2010

What have I done in 2010 ?
1. I started this blog in English( I have one in Romanian, too)

2. I have made a book (outdated) about ASP.NET MVC 2 tips and tricks , published on Amazon .
3. I have initiated a book about programming in VS2010 – alas, it’s in Romanian at http://ronua.ro/CS/media/p/216886.aspx

4. I have learned ASP.NET MVC by answering to the questions at 1146 and I have nominated moderator on ASP.NET forums.

5. I have made a project for Azure – it is call “backup” – a project that you can deploy on Azure and have abackup for your files – like Mozy or DropBox . It is here :http://myazurebackup.codeplex.com/
(and those are other mine projects on codeplex:

AjaxForWinForms
Change Data Capture Helper
CHM2Word
Cropper.TimeCapture
IEnumerable – DataTable Exp…
PrintScreen
SqlConsolidate
UsingLib
vhd to boot entry
windows azure backup

It was a good year for me!

Hope it was for you too!

About programming – 7 points

So many times I see people saying : “I can not have time to follow the tutorials – but give me some fast acces to some tutorials that solve my problem”.

I have

  1. Programming is not about code – programming is about decisions that you do about what code to write.
  2. Programming can not be learned by one tutorial – find more , skip it the obvious and read more
  3. Programming is not an easy job to do : you must have  knowledge (about at least the language used), it takes divide et impera and many more (testing being the obvious forgotten one …)
  4. Programming is a self-continuing learning : the products that you are using change – and I am more productive today with VS 2010 (and .NET4 ) than I was with VB  3 ( although VB 3 was EXCELLENT for that times )
  5. Programming is about experience : you can learn from others , but from yours mistakes , things that worked and right things ( my least : error to not de-normalize tables…)
  6. Programming is about keeping happy your technical leader ( or, if you are the technical leader, the project manager) . And I advise you to being one if you can, to see their problems.
  7. Finally  – there is not a royal way to programming  – take your time and enjoy!

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.