Friday, November 29, 2019

The Tutorials With Most Impact in 2019

After relating about tutorial hell in my previous posts, I wanted to present a short list with the most important tutorials of 2019, that impacted my developer life significantly. In total, I might have done maybe a hundred tutorials in this transition year, but some of them were so far - reaching, that they are the backbone of my current projects.


1. introduction to Dapper ORMhttps://www.youtube.com/watch?v=Et2khGnrIqc
additional materials were:
Advanced Dapper: https://www.youtube.com/watch?v=eKkh5Xm0OlU&t=3s
Stored Procedures: https://www.youtube.com/watch?v=Sggdhot-MoM
LINQ: https://www.youtube.com/watch?v=yClSNQdVD7g

2. Asp.Net Core - the basics
a. general introduction with MVC: https://code-maze.com/asp-net-core-mvc-series/
b. Entity Framework Core: https://code-maze.com/entity-framework-core-series/
c. Microsoft Razor Pages Tutorial: https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-2.2&tabs=visual-studio
d. A bit more advanced tutorial for Razor Pages: https://www.learnrazorpages.com/razor-pages/tutorial/bakery

3. Angular/Material Design/Firebase
https://angular-templates.io/tutorials/about/angular-crud-with-firebase

My applications in 2019 are very much dependent on the ideas and technologies mentioned in these tutorials. Of course, I studied additional techniques and ideas to fulfill my work, but these were the most interesting and impactful ones for me in 2019.

What are your main tutorials for 2019 or recent years?

Bulk Insert With Dapper - The Right One

One of my favorite online trainers, Tim Corey, introduced Dapper for me two years ago. It was only the last week when I stumbled upon his advanced Dapper video, and implemented the correct version for a bulk insert, using this micro-ORM.

Prerequisites:
- install Dapper nuget package;
- intermediate C#/with MS SQL database;

The task of our bulk insert will be to insert the following data into an MS SQL database:

a. Table structure in SQL, defined by the query:

CREATE TABLE [dbo].[InvoiceSummary](
[id] [int] IDENTITY(1,1) NOT NULL,
[Inv_Number] [int] NOT NULL,
[IssueDate] [datetime] NOT NULL,
[BillingCode] [nvarchar](100) NOT NULL,
[EntityName] [nvarchar](200) NOT NULL,
[BUName] [nvarchar](100) NOT NULL,
[Value] [float] NOT NULL,
[VAT] [float] NOT NULL,
[TotalValue] [float] NOT NULL,
[Currency] [nvarchar](50) NOT NULL,
[ExchangeRate] [float] NOT NULL,
[Entity_Id] [int] NOT NULL,
[BU_id] [int] NOT NULL,
[UpdatedBy] [nvarchar](100) NOT NULL,
[UpdatedAt] [datetime] NOT NULL,
[PeriodID] [nvarchar](50) NOT NULL,
[Comments] [nvarchar](200) NOT NULL,
[Comment] [nvarchar](200) NOT NULL,
[Status] [nvarchar](50) NOT NULL,
[AttentionOf] [nvarchar](300) NOT NULL,
[CC] [nvarchar](300) NULL,
[HFMCode] [nvarchar](100) NULL,
 CONSTRAINT [PK_InvoiceSummary] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[InvoiceSummary] ADD  CONSTRAINT [DF_InvoiceSummary_UpdatedAt]  DEFAULT (getdate()) FOR [UpdatedAt]
GO

b. There is a type defined, for the table-valued parameter, see SQL statement below:

CREATE TYPE [dbo].[BasicUDT] AS TABLE(
[id] [int] NOT NULL,
[Inv_Number] [int] NOT NULL,
[IssueDate] [datetime] NOT NULL,
[BillingCode] [nvarchar](100) NOT NULL,
[Entity_Id] [int] NOT NULL,
[BU_id] [int] NOT NULL,
[EntityName] [nvarchar](200) NOT NULL,
[BUName] [nvarchar](100) NOT NULL,
[Value] [float] NOT NULL,
[VAT] [float] NOT NULL,
[TotalValue] [float] NOT NULL,
[Currency] [nvarchar](50) NOT NULL,
[ExchangeRate] [float] NOT NULL,
[Comments] [nvarchar](200) NOT NULL,
[AttentionOf] [nvarchar](300) NOT NULL,
[CC] [nvarchar](300) NULL,
[HFMCode] [nvarchar](100) NULL,
[UpdatedBy] [nvarchar](100) NOT NULL,
[UpdatedAt] [datetime] NOT NULL,
[PeriodID] [nvarchar](50) NOT NULL,
[Comment] [nvarchar](200) NOT NULL,
[Status] [nvarchar](50) NOT NULL
)
GO

c. Stored procedure, to insert into our table, using table valued parameter:

CREATE procedure [dbo].[spInvoiceSummaryInsertSet]
@invsummary BasicUDT readonly
as
begin
set nocount on;
INSERT INTO [dbo].[InvoiceSummary]
           ([Inv_Number]
           ,[IssueDate]
           ,[BillingCode]
           ,[Value]
           ,[VAT]
           ,[TotalValue]
           ,[Currency]
           ,[ExchangeRate] 
           ,[Entity_Id]
           ,[BU_id]           
           ,[UpdatedBy], UpdatedAt
           ,[PeriodID]
           ,[Comment]
           ,[Status],
    [Comments]           
           ,[AttentionOf]
           ,[CC]
           ,[HFMCode],
   [EntityName],
   [BUName]
   )
SELECT [Inv_Number]
           ,[IssueDate]
           ,[BillingCode]
           ,[Value]
           ,[VAT]
           ,[TotalValue]
           ,[Currency]
           ,[ExchangeRate] 
           ,[Entity_Id]
           ,[BU_id]           
           ,[UpdatedBy], CURRENT_TIMESTAMP
           ,[PeriodID]
           ,[Comment]
           ,[Status],
    [Comments]           
           ,[AttentionOf]
           ,[CC]
           ,[HFMCode],
   [EntityName],
   [BUName]
from @invsummary


end;

d. Our original list in C# will contain the values we need to insert into the table:

// myInvList is a list of InvoiceSummary items defined by the class above at a)
InvoiceSummaryInsertSet(myInvList)

e. Our list is getting inserted into SQL Server DB using the table valued parameter

        public void InvoiceSummaryInsertSet(List<InvoiceSummary> myInvList)        {

            var dt = new ExcelServices().ConvertToDataTable(myInvList);

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
            {
                var p = new
                {
                    invsummary = dt.AsTableValuedParameter("BasicUDT")
                };

                connection.Execute("dbo.spInvoiceSummaryInsertSet ", p, commandType: CommandType.StoredProcedure);
            }
        }

f. helper function to transform a list into datatable, used above, is implemented as below:

        public System.Data.DataTable ConvertToDataTable<T>(IList<T> data)

        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(T));

            System.Data.DataTable table = new System.Data.DataTable();

            foreach (PropertyDescriptor prop in properties)
            {
                table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
            }

            foreach (T item in data)

            {

                DataRow row = table.NewRow();

                foreach (PropertyDescriptor prop in properties)
                {
                    row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;             

                }

                table.Rows.Add(row);
            }

            return table;

        }

That's all, it works ! Hopefully it helped some of you.

Thursday, November 28, 2019

The Challenges of Writing Business Apps/Tools


As mentioned in my previous posts on this blog, my developer journey began as an intersection between the corporate world (accounting) and programming. I used to support my own accounting processes and help others with various VBA/Excel, Access, SQL tools and that's how the journey began.

Outgrowing my role as a Management Accountant in this technological sense, in 2019 I began studying and writing full time additional applications for business/accounting problems.

The basic idea of the tools is automating Excel-based processes in a more coherent database-app approach. There are a lot of struggles in my journey, but and I have learnt a lot, especially .Net technologies and SQL, and in the meantime, the web-stack using JavaScript and lately ASP.NET Core/Razor pages.


Clearly, the biggest challenge in all these is the mapping of real world processes (based on Excel and manual work) to an application. What's needed for this to be successful? In no particular order, my conclusions are:
1. very good understanding of the processes. This takes time and lots of communication/questions.
2. Understanding inputs and outputs. Data structure, types, formats, steps, validation, internal checks of the applications, stages of completion, reports, application logic and flow all come from inputs and outputs.
3. Thinking about the entity/DB structure and program flow.
4. From the mental mapping above come the DB structure, and then flow. Usually the flow is the succession of operations: input data, review data, edit, delete, search, etc, add more data, filter, prepare intermediary reports and then further add data, filter, edit if needed and then generate final outcome (reports, files). This cycle above can have multiple stages and checks/reports built within.
5. Validate the proposed process with the customer.
4. Discussing old methods vs new optimized process: lessons learned and areas to improve on in the new system based on feedback.

My big projects in the last 2 years are:
1.  Manufacturing Reporting/Statistics tool in MS ACCESS, on key phases of the production line. (manufacturing shop floor).
2.  Internal recharge system of the company, for distribution of indirect/administrative costs. Technology: C#, .Net, WPF/MVVM and SQL Server
3. My current project is an invoicing software that collects and invoices costs by employees. Using same technology as above. + Asp.net Core Razor pages
4. Another project for 2020 will be a VAT reporting tool to automate an Excel-based approach inside the accounting department, consolidating, filtering, automating data collection from several internal business units (big departments), and preparing statutory reports for Value Added Tax.

Some clear lessons to change the Excel-Based approach into a more efficient application are:
1. Using one database instead of many files, on a central server/Azure, for each app.
2. Mapping the entities from the excel files => as database tables/ and POCO entities.
3. All the automation of the repetitive processes go to C# code = > helper, data manipulation functions, using LINQ with lists etc.
4. Report generation, using ReportViewer tool, or ClosedXML to export excel files upon request;
5. Code re-usability.

Some architectural conclusions of the journey are:
1. need to manage the users of the application
2. implementing a reporting system, with parametrised queries, using SQL/Dapper/Reportviewer and/or simple Excel reports
3. implementing a concept of "Period": the accounting month in which all transactions take place. Afterwards the period is closed, and next month is opened for another series of transactions.
4. Implementing different types of Tables / entities by functionality:
  • tables with reduced number of updates such as business units, customers, users
  • tables with some  more frequent updates (such as employees, price lists)
  • transaction tables (allocation keys calculated, monthly cost information, monthly invoice details, etc)
5. For transaction tables, insert the user and transaction date/time 
6. In some special cases, implement a history table for some entities for which the change log is important  (such as employee change history).
What do you think, what are the main points of producing such business/accounting tools? Would you do something differently from an architecture standpoint?


Monday, November 18, 2019

Why Microsoft Excel is So Popular - My Opinion



MS Excel is the most popular member of the Office family. Nothing can rival its popularity, and still today has no contender in the application world. Google Sheets, Libre Office, Open Office, are just pale imitations of what it can do. We are in the age of database applications, Sharepoint, Mobile and Web apps, and still, MS Excel flourishes.

As a former Management accountant myself, I used MS Excel a lot. Even having many internal tools, applications and databases, Excel was the most widely used, just for everything.


Still, it has some disadvantages that makes an application more viable, and I'll explore that later.

So, why is Excel so popular:
- no training is needed, you just open a sheet and type in information, write easy formulas
- no additional applications need to be installed (frameworks, databases, run-times)
- the file format is universal. Linux and Mac OS, mobile phones, web apps all can read and write to Excel.
- all kinds of activities can be done in Excel, such as:
  • store data. Its sheets are like database tables, you can save data in them. Thousands of rows, and Excel can manage them quickly.
  • filter, find, summarize, report on data. Filters, pivots, charts are very easy mechanism to analyze and search for data. No other tool can rival the ease of doing this.
  • Formulas - it lets you build scenarios, budgets, calculate, optimize and simulations. The flexibility is just unparalleled.
  • VBA : you can automate your work with programming. Very easy, using Visual Basic language.
  • Lots of other functionalities: statistical functions/packages, connections with databases, and the web, etc
  • Extreme flexibility: add comments, edit fields, change formulas, with a click.

Still, Excel has some disadvantages, mostly coming from its advantages:
  • cannot deal with big volumes of data. Starting with 10k rows in a sheet, things become slow and unpractical.
  • extreme flexibility has a cost. Data can be changed, formulas erased, information lost... and sharing the data is not efficient, leading to duplication, misunderstanding. The risks of running lots of complex data in Excel are very high.
  • Filtering and data search functions still have some limitations. SQL, in my opinion, is more powerful. (and harder to write, also)
  • VBA, the programming language and system of macros behind the data sheets is not efficient and clean code, scalability is an issue. You can use for simple things,but when there are multiple users, lots of data, complex business logic, a modern language such as C# can deal with these in a better way.
 
Somebody said that the 70% of all business logic of companies is in Excel. Working 15 years in a corporate environment (4 big companies), I can confirm this. Excel is the first option, when it comes to data analysis, reporting etc.

Do other applications have any chance to develop and flourish? Can they help to automate things and make life easier in a company? Yes and no.

Let's have a look to the possibilities for substituting MS Excel with an application.
Pros:
- in the case where the rules are clear and established, and the volume of data is big, an application makes more sense. 
Cons:
- where the data is small, and/or the rules are changing and much flexibility is needed, Excel is still a better solution.

So what's the right approach to substitute the bad part of Excel? Probably understanding the constant, rule-based, or algorithmic part of business processes, and write applications for them, while still using Excel in parallel to solve smaller, flexible tasks.


What do you think? Would you write an application to make Excel based processes more efficient?


Tuesday, November 12, 2019

Working from Home as a Developer

Remote work is trending in the last couple of years. And more and more, regular office jobs in big companies get days to work from home, even if they are not from the Tech area. As I was a corporate accountant before, I never experienced home-office or remote work before, but this year was the beginning!

I've been working from my home office since March 2019, and let me share my experiences.
First of all, I needed to make sure I can work comfortably from my home office desk, and for this I have a big screen monitor with a docking station and a good 14" laptop.

What are the advantages?
  • I can manage my time. Normally there is no pressure, I can prioritize my work and day.
  • No workplace stress, conflicts with coworkers, micro-managing boss etc. This is very appealing!
  • I can make as many breaks, or I can work as long as I wish.
  • I can listen to music, in the background.
  • I communicate by email, so there is not much interruption during the day.
  • I can make a big break in the middle of day to do the groceries, gardening, swimming, shopping etc
  • I can take days off or even a mini-vacation without disrupting my development process.
But there are disadvantages, also:
  • I need to plan my week to know what are the priorities. Nobody will tell this to me.
  • I have to be very careful with the pace. Not too much work, not too less. 
  • I really need to do some exercise, otherwise my concentration is going down.
  • There is a risk that I eat too much and have too less exercise => I might gain some weight.
  • Some isolation and loneliness, which I try to balance with exercise and reading, and study of new instrument.
  • Distraction - looking to youtube videos or just doing other things than work.
  • Fear that I will be left behind in terms of technology.
  • Not much technical supervision and mentoring, I need to research all the unknown technical stuff for the project. This requires some confidence and courage to find workarounds if the ideal solution is not found.

What do you think, would you work as a remote developer? Or anything, from home?

Business Logic of an Application - My Experience as Newbie Programmer

If you read my other blog posts, especially the first ones, I explain there that my background is 15 years of corporate controlling (management accounting). And 2019 was for me a transition year to - writing accounting/business software. I accumulated some SQL/C# skills in the past years, and using my business knowledge and logic, I try to build some real tools from my previous workplace's accounting department.


I can state at the beginning that having an accounting/controlling background is very useful to understand the logic of my apps. Their goal is to automatize the work of accountants, to reduce to minimum the need of using Excel files and many emails for data collection, approval etc. So, my business background proves to be helpful!

Afterwards, comes the design and programming part.


First I design the database, using an abstract model of the data that can be used in the app.

Understanding table structures and relationships in excel, and the workflow, I can build the SQL tables and relationships, keys,  indexes, queries and reports that can be integrated to the application. I do this without having a formal training on how to build business applications, just following simple logic, then some database theory, SQL knowledge, normalization, etc.

Then I design the code and start writing it.

The models of the app are representing these SQL tables and relationships, and are the foundation of the application. Example: Business Units, Employees, Expenses etc.

Then comes the application layer, with MVVM -  a viewmodel that takes care of data coming from and going to the database, manipulating user inputs, checking, validating, iterating, etc...

Then there is the View of the application - WPF - for Windows interface, which is quite simple, user screens with tabs, tables (gridview), inputs, and reports, exports, imports of data. I try to make the user interface simple and easy to navigate, with a minimal risk to do stupid things. The users are happy, because they can use a centralized database app, and thus we can eliminate a lots of emails and excel files, which are very prone to error.

As I progress with my application, I go back sometimes to redesign the database (add fields, indexes, tables), and also the code of MVVM above. This is an iterative process for me, like continuous improvement.

Last step is to populate with data, and check. This is the most time consuming part, and can feedback to  database design and coding.


What do you think? Would you do something differently? Please feel free to give me feedback on the above topics.


Thursday, November 7, 2019

Bulk Insert in Dapper into MS SQL

I am collecting costs by employee from 6 sources and then insert them into a a GeneratedDetail table. But the collected data has 1000+ rows, and the insertion one by one row is very slow. I needed to find a bulk insert solution.
SQL Server DevOps
I am using Dapper as ORM in my C# project, and MS SQL Database.
According to research, my approach would be as below. It works now quite fast, I am satisfied with the speed of execution. Feel free to comment and propose a better solution.
note: spGeneratedDetailInsert  is a stored procedure with many parameters.

        public  void GeneratedDetailInsertBulk1(List<GeneratedDetail> DetailList)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
            {
                var sql = "";           
                foreach (var mydet in DetailList)
                {               
                    sql = sql + "Exec spGeneratedDetailInsert '" + mydet.BillingCode + "', " +
                        mydet.Emp_id + ", '" +
                        mydet.Emp_name + "', " +
                        mydet.HrId + ", " +
                        mydet.Entity_id + ", " +
                        mydet.BU_id + ", '" +
                        mydet.Currency + "', '" +
                        mydet.Item + "', " +
                        mydet.ExchangeRate + ", " +
                        mydet.InitValueRON + ", " +
                        mydet.InitValueCurr + ", " +
                        mydet.MUValueCurr + ", " +
                        mydet.TotalRon + ", '" +
                        mydet.ServiceType + "', '" +
                        mydet.CostCategory + "', '" +
                        mydet.UpdatedBy + "', '" +
                        mydet.UpdatedAt + "', '" +
                        mydet.PeriodId + "' ; ";                                   
                }
                 connection.Execute(sql);
            }
        }
Note: I am not using Dapper Plus, and I don't want to.

Dapper Plus | Learn how to use Dapper Bulk Insert with ...

Wednesday, November 6, 2019

How to Calculate Estimated Time Left in C# for Time-Consuming Process



I can suggest my today's discovery for estimating the seconds left in a 3 minutes process in C#.
Anyone better approach?

            Stopwatch sw;
            long totaltime = 0; // counts the total time passed in milliseconds
            int secondsleft; // estimated time left
            int i = 0; // counter in the foreach loop
            // objList has couple of hundred elements
            //secondsleft is recalculated after each iteration

            foreach (var obj in objList)
            {
                sw = Stopwatch.StartNew();
                //some time consuming process here
                i++;
                totaltime = totaltime + sw.ElapsedMilliseconds;
                secondsleft = (int) Math.Floor((double) totaltime / i / 1000 * (objList.Count() - i));
            }

MCSD Certification - Would You Take It?

Anybody here have experience with MCSD?
Would you it recommend to me, as a junior/mid level developer?
Resources I could find about this are:
https://www.iamtimcorey.com/blog/137740/certifications
https://dotnetplaybook.com/how-much-did-the-mcsd-cost-me/

10 Things All Web Developers Should Learn

One of my Youtube Heroes, Brad Traversy Posted This:
I fully agree, and already practice some of the points he mentions:


What do you think, you should change or add in his list?

Corporate Life - The Good And The Bad

After 15 years spent in the corporate world, I could draw some conclusions. There are good and bad parts, and I will describe them below. I enjoyed it, until it was enough. I do think that being in a part of the world (Eastern Europe) where the government, trying to attract multinationals, will do anything to give them power over the employees. This makes the life of its citizens limited somehow, even if this is a chance to raise above the average national level, in many terms.


The good part working in a multinational company:
1. learning processes, procedures, working with proper tools
2. really specializing in your field, getting some good training and paid courses (my CIMA certification was paid by one of my former employers - and this is a big amount!! thousands of EUR)
3. working with some true professionals, and seeing good examples
4. earning above average salary, after the 5th year of employment.


The bad part:
1. being constrained and controlled by processes, systems and, managers (sometimes micro-managers)
2. must show up every day, for 8 hours (why not working from home, remote??)
3. not so great colleagues. In my area, there are too many companies that cannot form train their people. They all want trained people... but what they find on the market are not properly trained, junior people... and their formation takes years. Imagine, after 10+ years of experience, your colleagues are still junior, and they don't understand sometimes the basic aspects of their jobs.
4. Y-generation, millennials. The youth (30 and below) is not prepared to work seriously. They want much more salary for the same work, and they will boycott their employer... low pay, low commitment! It's a pain to work with such people.
5. Somewhat limited perspective to grow. The main goal of your manager is to keep you in place and increase your efficiency, not increase your position and real experience/variety of skills.
6. Stupid processes and systems. No documentation, no experts to learn from, everything done in the last moment...
7. the senior manager sees Eastern Europeans as a cost, an expandable resource. To generate profit for them. Nothing more. You are a peon in their game.


This video from grindreel summarizes the bullshit culture very well:
https://youtu.be/gMwUNVNZUmc

Angular Material - I like it, but...

After learning some HTML/CSS this year earlier, and working through my Angular tutorials, I stumbled upon some really nice design systems.

One of them being Angular Material.


And just discovered couple of others, such as Nebular and NG bootstrap.

All of them are beautiful.... The material one, I tried in several tutorials, I show the main ones here:

1. Some easy ones
2. I replicated this one in one of my mini-projects
3. This is a more serious one, but I could follow it.

I would like to study this more in depth... but I just was lacking the time to deepen my journey in this area. Angular material is beautiful, just I don't have time right now. It is a project for 2020, like many others :)



What are your experiences with Angular Material? Or any other design systems, such as https://materializecss.com/ ?

Do you have some tutorials for them?

Tuesday, November 5, 2019

Programming Is The Easy Part

I was wondering lately what is the real challenge in my current project, and what is the easy part. Do I manage the challenges the right way? Can I find some optimizations?

My answer to the challenge question is yes, there is a challenge. Understanding really well customer requirements is. What is the business process behind? What are the entities and properties?
What tables to I have as an input? Fields set as a flag? Certain situations require different treatment?
How much freedom has the user, to manipulate or corrupt data?

Yes, processing the real data that goes in the application is the real challenge, mapping it to entities that can survive the changes of the life of the application.

And what to do when the input data has some flaws? Data duplication, bad codification, violation of uniqueness... how to bridge this in my database?

Writing code is the easy part.

1. there is some routinely written code: SQL queries  - 80% are repetitive, following the same pattern (not exactly same commands). Writing the entity classes and the ORM functions that map DB procedures to entities, almost totally a routine.
2. Some semi- routinely written code - linking the WPF layout with bindings to entities, setup the ViewModel and View, draw basic XAML (copy-paste, than change)... Oh how I hate this XAML.

3. The interesting part is to write some algorithmic functionality: saving files and creating emails, generating views with filtered data, writing some more complex LINQ queries, generating invoices, creating Outlook Emails, Reports with Reportviewer...

What is then the hard part?

I think understanding the requirements really well and mentally mapping out a process how to tackle the solution step by step. Visually, View by View, Tabs, Tables, Reports, and a general succession.

Then comes the execution, test, populate with data, correction, again test, again addition of data, etc.


And finally the customer feedback, and again, corrections, optimization, refactoring, test, submission to the customer.

And after several attempts, there is the prototype that can be used at least on the short term, before the next iteration.

That's my approach. What do you think, what's your process?

Lots of SQL today

As part of my big project, today I dealt with some table creation and query writing. Mentioned earlier, I use Dapper as ORM and this means no EF queries are generated automatically.
So all Insert, Update, Select etc queries have to be written manually and returned and mapped to POCO entities (simple classes) via Dapper.



I think 2 hours was spent today on this.

I created 3 big tables (10+ fields) and wrote all CRUD queries as mentioned above.

Then, using a helper class, the ORM mappings are written in one place, just to call these functions within the application, when needed.

Some demo, from Tim Corey: https://youtu.be/QVkpzuiiVtw

An the foundation, for Stored Procedures, I used this: https://youtu.be/Sggdhot-MoM

What do you think? IS EF much more efficient?

By the way, my small prototype project in .Net core Razor Pages uses EF Core, which I wanted to learn step by step to get accustomed to it. It is nice, too, I like it! For a simple web project, it is enough for my purposes.

Monday, November 4, 2019

.Net Developer - and former accountant?

During the past 6 months, my projects, the old and new one, are basically accounting applications. So my basic background is a great help!

But how can I compare and contrast these two professions?

Programmer vs Management Accountant (Controller)

Common things:
1. focus on details
2. sitting in front of computer
3. many tables (in excel or SQL)
4. some business logic (more on user level as accountant, more on designer level as programmer)
5. lots of patience
6. need to do some exercise
7. need to study and improve - lots of self-study


Differences
1. as an accountant, the pressure was way higher - deadline, audits, not working systems
2. as home based programmer - I deal with much less interaction. It is a bit boring, but stress level is not existing.
3. as programmer - materials are freely available to try and learn. As a finance controller, the company systems were not at all documented, and it was a huge struggle to understand and configure them, beside the daily pressures.
4. as a programmer - more helpful community and possibility to learn at own pace. As controller, the priority changes were more sudden and imprevisible, with almost no support from management.

That's all for now. What do you think, did you experience this kind of transition? Do you feel stressed as a programmer? Or lacking support?


Career transition - from Finance to Developer at age of 39

This is an interesting story. I used to be a finance professional, qualified management accountant in the local industrial zone. But, as I got into programming and deepened my knowledge, I started gaining some traction and started liking it more and more. I decided to quit the world of deadlines, stress and audits and to switch to something more creative.

The transition took approximately 12-16 month of parallel time:
- I was working full-time
- in the meantime I spent weekly 2-4 hours to study C#, SQL or work on the .NET project (internal recharge system)
- and thinking about when to make the transition.

The nice part about the learning process was:

  • already familiar with some programming, like Access DB, VBA, Excel, some php&mysql
  • familiar with tabular data and databases + SQL (I used to write some queries in my previous workplace, obtaining some data from the company ERP)
  • I always enjoyed learning, and could focus very well
The hard part:
  • the learning curve for C#, WPF, MVVM and Dapper ORM was steep. It took 6-10 months to show some results
  • I became tired after 1 year, working paralelly on the project besides my day job
  • frustration after 1 year, having seen the results, and not knowing what's the best thing to do: to quit or to do it paralelly for some time
  • became really tired at the end of 2018 by working parallel. I decided that early 2019 I need to quit and go full time into programming.

What I like about C#?

C# has been my main language of choice. I use this for my big database application, and have played with it to build some Rest API and also for Razor Pages.

It is an awesome, all-round language.


My main sources to learn it:
1. Google/stackoverflow
2. https://www.iamtimcorey.com/
3. general tutorials and questions from the internet

The nice part about the language is:
- structured, logical
- it has LINQ to manage lists - fantastic!!
- IDE from VStudio 2019 is more than helpful
- lots of tutorials/error situations on google

The less ideal part about the language is:
- linked to .NET ecosystem, you have to be lucky to find some solutions online
- could be more free tutorials tailored for beginners
- struggled to find some good live courses in the neighborhood, I needed to learn alone
- some learning curve - maybe the first year in 2017 and early 2018 (1-2 hours per week, without supervision)

What do you think about the easy and hard parts? Any ideas how to deepen my knowledge?

Javascript - the biggest discovery of 2019

As I mentioned earlier ,  I had the occasion this year to learn Javascript. And later a little bit of Typescript together with Angular.

This was a major breakthrough for me, because I did not know almost any of it before!



The steps of learning were the following:
1. learn syntax, basic structures
2. array, string, date functions, IIFE, arrow functions, callbacks
3. classes and objects
4. promises and Fetch function, a little bit of async/await
5. learn node.js, with express and mySql database.

Finally, I was able to build small APIs to Insert, Update, Delete etc data from a MySQL database.
This took aproximately 3 months to master, with weekly 8-10 hours as average. I kept a constant pace, solving a lot of small exercises in the beginning. As I mentioned, this was part of a code-camp called Smartware Academy, organized by a local company.

Some of the resourced I used:
Then, behavior of DOM -> very useful https://www.w3schools.com/js/js_htmldom.asp

The easy part was:
- similarity to known languages (C#)
- a lot of resources and tutorials online
- some good support from the mentors in the course

The hard part was:
- constantly using console.log to show the values of variables during execution/debugging
- DOM - new concepts and behaviour
- callback functions - really strange - and callback hell

Finally, lately I got into a little bit of Jquery/w bootstrap. Really useful, this is still ongoing for me as I want to integrate this into my Razor Pages application.

And now about Angular -  I did quite a few tutorials (maybe 30-40 in total), as I described in my blog post. And yes, I would like to deepen my Typescript experience, since this is one of the coolest trends in the Web stack. I mean, really useful, especially if you come from the C#/Java world, some concepts are borrowed to make your life easier in Javascript.


PS: Does anybody have good ideas about learning Jquery with bootstrap?

Sunday, November 3, 2019

Razor Pages - Not For Shaving!

This is absolutely fantastic! Easier to understand than MVC, and some additional features vs old .net Razor pages! Using Entity Framework Core.

What is Razor pages?
  • ASP.NET Core Razor Pages is a page-focused framework for building dynamic, data-driven web sites with clean separation of concerns. 
  • Razor Pages can make coding page-focused scenarios easier and more productive than using controllers and views.

Best tutorials, I did them all:
1. https://www.learnrazorpages.com/razor-pages/tutorial/bakery
2.  https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-2.2&tabs=visual-studio
3. https://kenhaggerty.com/
4. https://www.codeproject.com/Articles/1263791/ASP-NET-Core-Razor-Pages-Using-EntityFramework-Cor
5.https://www.youtube.com/watch?v=vh0UqlnM0Jw

Currently I build a small project, using EF core, which connects to an Azure database.It has aprox 15 pages, and uses a lot of Linq expressions.
Guys, did any of you have contact with this technology?
Do you have any tips?

How to be MEAN?

During the spring and summer of 2019 I had the occasion to study some web development, including Angular and some Node.js.

But I feel that is just the beginning... one of the directions I would like to deepen this is to do some more realistic tutorials and apps in the MEAN stack.
M = Mongo DB, I already use this for some of my tutorials , I hosted some sample DB here: https://cloud.mongodb.com/
E = Express.js, which is a web framework within Node.js
A = Angular
N = Node.js, which I studied for 1-2 month during summer of this year.

Currently I don't have the time for this stack, so I put it on hold...
Still, Angular+Firebase, Angular+Material design and Node.js + Mongo.DB is something I want to check out in more detail than before. Perhaps an idea for 2020 :) I have too many ideas already!!! Can somebody help to prioritize? Maybe this is being MEAN?

My Youtube Developer Heroes

This is a list of my favorite development youtubers, who are an inspiration for me and whose tutorials I usually watch aproximately on a weekly/daily basis.

1. Tim Corey. He was my starter in many areas for .NET, and I thank him for this.
https://www.youtube.com/user/IAmTimCorey/videos

2.  Brad Traversy - web development, very broad and new material
https://www.youtube.com/user/TechGuyWeb

3. Fireship.IO. Honestly, I fell in love with Angular and Firestore NoSQL database. This channel is the main cause for this: https://www.youtube.com/channel/UCsBjURrPoezykLs9EqgamOA

4.Academind. Just as Brad Traversy, focus on web development:
https://www.youtube.com/channel/UCSJbGtTlrDami-tDGPUV9-w

5. Developer lifestyle and work-life balance, lessons learned:


What about .NET Core? My new target.

During September 2019, I have been awarded a second bigger project.
It is an invoicing software, which collects various costs for employees (compensation/salary, management fees, depreciation of equipment, administration cost, miscellaneous costs) and generates a recharge invoice for their respective clients. It is a Shared Service Recharge Invoicing system.

Tools used:
- WPF and MVVM with .NET (C#).
- MS SQL for database
- Dapper as ORM
- .NET Core Razor pages (.net core 2.2) for a special manager module, for manager being able to review their employees invoices 
- bootstrap as default css system for Asp.net web pages
- some jquery

For Razor pages, I needed to learn following technologies:
1. EF Core - best, and really SIMPLE, useful resource I found: https://code-maze.com/entity-framework-core-series/
2. .NET core with razor pages. Excellent resources:
I really like Razor pages, and I will write a separate blog entry for this topic, elaborating a bit more on this. Until now, I really like it, and started to progress really well during the past days.
PS: Razor Pages are now the default in the Web App category/Visual Studio!


Angular? This is real tutorial hell. (but it's worth it)

During the summer of last year, one of my friends I used to go swimming together, mentioned he recommends Angular to me if I want to learn programming seriously.

What an idea...

In February 2019 I started to study Angular and do lots of tutorials. Besides my course and big project which was finalized in summer of 2019, I studied this Javascript framework.

Imagine, I started doing Angular tutorials, and parallelly learned Javascript (ECMA 2015).
My main source of angular tutorials:
- https://angular.io/tutorial
- lots of smaller, simple tutorials : https://javabrains.io/courses/angular_basics/
- later on angular+firestore: https://fireship.io/
- some angular + material tutorials

It took me about 6 months, with weekly 1-2 tutorials, some of which have been quite superficial, copy paste etc. That's tutorial hell! I think now I am the best at faking angular tutorials... I became MEAN in the meanwhile, going through this hell.

Imagine my frustration in the beginning trying to use Web-API for back-end... from .net core and node.js... but that's a different story, maybe for another blog post.

But, around June 2019, I succeeded with some nice applications, one of which I can show below:

https://songlist-varad.firebaseapp.com/



To be honest, it is a replica of an existing tutorial, tailored to my needs:
https://angular-templates.io/tutorials/about/angular-crud-with-firebase

In spite of all odds, this Angular hell has some value. It was hard, steep learning curve. But now I know I don't have to be stopped by new technologies or complex code. Everything has to be taken slowly, maybe only 20 min of focused learning per day. Excellent source was : fireship.io.

This HELL - is worth it!!

Journey to Web Programming

After my big project began to finalize, I decided to quit my day job as controller.  In the meantime I had the opportunity to participate in an intensive Web-Development class locally, organized by a local Software Company.

https://www.smartware-academy.ro/

Lessons learned during the 12 week course were:
  • html with css (for me css was quite new!!)
  • Javascript, basics, classes, algorithms
  • Node.js with MySQL for back-end
  • we constructed a Note-manager, a small application similar to a mini-blog, called Smart Notes
This was an excellent opportunity! I learned JS here from scratch - really focusing on technique and self-discipline. I took all the steps slowly but steadily, almost every day exercising, doing challenges etc.

Node.js is fantastic for creating fast back-end projects. We used simple node.js web-apis to get and post data to the mysql database (notes, users, pictures).

Tools used:
- Cloud 9
- VS Code
- no CSS framework
- html and css written in "notepad" style
- NodeJS with express.s


This journey lead me to deepen my interest to web-programming, the MEAN stack in special.
 
I did this course while finalizing my big project, mentioned in my first two posts. I do think I added a lot to my C# knowledge, and I recognize Javascript is the biggest discovery for me in 2019!

My first big project (.NET) - and technologies used.



In the summer of 2017, together with my former finance manager, I began to design an internal recharge system for the company.
The choice was WPF for Windows (https://docs.microsoft.com/en-us/dotnet/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application) using the old .NET, and an MS SQL Database.

We began to learn, exercise and think about the tools to use:
Our inspiration was: https://www.iamtimcorey.com/
1. IDE: Visual Studio Community 2017
2. WPF - for the visual part, front-end
3. ORM - Dapper - I think this is the best discovery ever! Tim speaks about this in his Videos.
https://www.iamtimcorey.com/blog/137806/entity-framework 

Please, check out his videos, about SQL, C# and lots of serious tutorials and courses.
 (https://stackexchange.github.io/Dapper/)
See also: https://dapper-tutorial.net/
4. MS SQL - I needed to review my SQL knowledge. Did a lot of exercises, and build many stored procedures for the application - dapper maps the entities to the data returned by those stored procedures, and I also used SP to insert and update entity data. Even if this was very time consuming in the beginning, proves to be very efficient and goal oriented.
5. lots of company data about expenses and the algorithm to create allocation keys - business logic designed together with Finance Manager.

The journey was hard. It took me probably 1 year to really get some speed, and show something to my Finance Manager colleague.

Luckily, I had my finance background, to understand the process we tried to automate, as there was a working excel macro/formula model as well used before the application.

But, I needed to fix my knowledge of C# (also using MVVM the first time for WPF) and SQL/Dapper. This meant weekly 2-3 hours of coding for 1 year to get some traction.
Main source for C# was google and Tim Corey, and my big discoveries were:
  • lists/collections of items 
  • LINQ and the foreach 
  • breaking down the tasks to smaller chunks and functions
  • writing a services class to export lists to excel using OpenXML
  • first steps in async/await

A special challenge was how to integrate the good old WinForm control ReportViewer into WPF and MVVM. I will detail these maybe in another blog post.

My Background - from Zero to Hero!

Hi All,

I appreciate that you are checking out my journey to software development.
As a first step, I want to mention that I possess no degree in computer science. During my high school years, programming was taught in weekly 4-6 classes, so it was an intense experience! But afterwards, I studied finance at college, and programming remained a hobby, some excel macros and SQL queries, maybe Access databases.

During 2017, I got encouraged to create an internal system in my former company. It was about automating an internal cost recharge process! Of course, the choice was an SQL database, and a Windows application.

The rest is history.

PS: 
As for fall of 2019 the application was sold to that company, and I quit my day-job as a finance controller!!! Today I am a self-employed programmer in my natal city, and besides my second big project, I do learn new stuff almost weekly.