Friday links 129

  1. 10 Articles Every Programmer Must Read – I am programmer
  2. The Netflix Tech Blog: Making the Netflix API More Resilient
  3. Circuit Breaking With Polly | jaywayco
  4. The Circuit Breaker – That Extra Mile
  5. Release It!: Design and Deploy Production-Ready Software (Pragmatic Programmers): Michael T. Nygard: 9780978739218: Amazon.com: Books
  6. Visual Studio 2013 – Expand Visual Studio 2013 with Extensions
  7. Windows Visual Studio 2013 SDK Samples
  8. GitHub Student Developer Pack – GitHub Education
  9. Scripting Languages You May Not Know – Dice News
No Comments

Asynchronous code and exceptions

There are 2 kinds of coding when handling asynchronous code.

The first one is  calling Result:

<

t.TwoTask().Result

The second is async /await

public async Task<bool> TwoTask() {

//code

await Task.WhenAll(file, console);
return file.Result & console.Result;

}

As such, we will have 2 intercepting code.

For the first one we will catch AggregateException

try
            {
                Console.WriteLine(t.TwoTask().Result);
            }
            catch (AggregateException ex)
            {
                Console.WriteLine("Aggregate number of exceptions :"+ex.InnerExceptions.Count);
            }

For the second one we will catch the FIRST task  exception  ( or , more generic , Exception ) – and see what other tasks have been doing

try

try
            {
                await Task.WhenAll(file, console);
                return file.Result & console.Result;
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine("Exception is " + ex.Message);
                
                if (file.IsFaulted)
                {
                    Console.WriteLine("file is faulted exceptions :" + file.Exception.InnerExceptions.Count);
                    
                }
                if (console.IsFaulted)
                {
                    Console.WriteLine("console is faulted exceptions :" + console.Exception.InnerExceptions.Count);
                }
                
                throw;
            }

Maybe it is better when you see a video demo: Async await and exceptions at https://youtu.be/1a9s74IfSE8

No Comments

Friday links 128

  1. 700 Free eBooks for iPad, Kindle & Other Devices | Open Culture
  2. Falsehoods programmers believe about addresses
  3. Uwe Hermann on Twitter: ""Falsehoods programmers believe" series: http://t.co/HkhmU48fZ6, http://t.co/hZlB4kjjie, http://t.co/9MErWimCra, http://t.co/8zXFaSpmqm"
  4. WebAPI Generic
  5. ASP.NET MVC 6 attribute routing – the [controller] and [action] tokens – StrathWeb
  6. Ten Tips to Being a Great VB Developer
  7. Big Data Knows When You’re Going to Quit Your Job Before You Do – Bloomberg
  8. KeLuKeLu Games on Twitter: "Job hunting as a software developer. http://t.co/F5WDUu8i7a"
  9. Government fires employee who skipped work for 24 years
  10. philsquared/Catch
No Comments

Async / await transformation and pitfalls


    /// <summary>
    /// please read first http://blog.stephencleary.com/2012/02/async-and-await.html
    /// </summary>

Let’s say you want to transform this code to async / await

public bool TwoTask()
        {
            var file= WriteToFile();
            var console= ReadConsole();
            return file & console;
        }

The first version is


public async Task<bool> TwoTask()
        {
            var file=await WriteToFile();
            var console = await ReadConsole();
            return file & console;
        }

Why is not good ? Because it executes in serial the file, and then the console code

The good version is


public async Task<bool> TwoTask()
        {
            var file=WriteToFile();
            var console = ReadConsole();
            await Task.WhenAll(file, console);
            return file.Result & console.Result;
        }

You can see in action at https://youtu.be/02oO0YaTEyM

No Comments

Friday links 127

  1. Strip creator
  2. Born to Learn
  3. Applying NASA coding standards to JavaScript | Pixels Commander
  4. MSDN Blogs
  5. Monetization with PubCenter Ads – Creating App ID and Ad Unit ID – Quick Thoughts – Site Home – MSDN Blogs
  6. Lizard Stresser Runs on Hacked Home Routers — Krebs on Security
  7. Statisticians in World War II: They also served | The Economist
  8. Book titles with full-text online | The Metropolitan Museum of Art
  9. From the Archives
  10. What Just Happened? – AVC
  11. What Is Going To Happen – AVC
No Comments

Friday links 126

  1. Comparing Go and .NET // Justin Beckwith
  2. » What is the Oxford comma and why do people care so much about it?
  3. » 8 of the Funniest, Most Sarcastic Greeting Cards of All Time
  4. How a Web Design Goes Straight to Hell – The Oatmeal
  5. Comics :: Popular – The Oatmeal
  6. You Don’t Have to Hate Your Job – NYTimes.com
  7. The 22 Most Brilliant Life Hacks Every Human Being Needs To Know
No Comments

Friday links 125

  1. 5 Creative Design Ideas Using Grids – Design School
  2. 9 GIFs That Explain Responsive Design Brilliantly | Co.Design | business + design
  3. Pumpipumpe | a sharing community
  4. The AI Programmer’s Bookshelf
  5. Practical Tips for Web and Mobile Usability Tests
  6. Edward Reynolds on Twitter: "http://t.co/FjnCknj4CA"
  7. IT Pro New Year’s Honours List 2015 – TechNet UK Blog – Site Home – TechNet Blogs
  8. Web API OData V4 Lessons Learned – DavidHardin – Site Home – MSDN Blogs
  9. Postcode Lookup with YQL and Great Maps
  10. Do elite software developers exist?
No Comments

MVC-Planning Poker – Architecture versus unit testing fast

Now I have arrived to the moment when I want data to be persisted on disk. I choose SqlIte – because EF 7 is not yet on the market and SqlIte  could work on Windows Phone / Android.

So now I want to just serialize TableData and save . To serialize I have several options – yesterday was XML, not it is Json. The Newtosnoft Json library could do the serialization – and with SqlIte I could put into a database file.

 

However, the problem is with what we have for serialization / deserialization and how we have conceived the software.

For example, Table class does not have a public constructor – a Table does not exists without a Moderator to create it – and which Cards to display

internal Table(string moderatorName, List<Card> cards = null)

For Deserializer to work, the Table either should have a public constructor

p

 public Table(): this("", null)

, either  the deserializer will have a function to construct the Table.

The first option means that the architecture will be somehow not so good.

The second option means more work for the programmer.

In .NET we have the third option – we can use obsolete:

 

[Obsolete("Use CreateTable from TableFactory",true)]
        public Table(): this("", null)

The true option means raising an error when we COMPILE code that uses the constructor – not at run time, when the deserializer uses it.

So we maintain the architecture – and not enforce at run time.

If we wrote

 Table t = new Table();

the compiler gives

1>D:\sourcecontrol\Vs\MVC Planning Poker\PlanningPoker2013\PPTest2013\SerializeTableData.cs(68,23,68,34): error CS0619: ‘Table.Table()’ is obsolete: ‘Use CreateTable from TableFactory’

 

However , the serialization uses happily the constructor – even if it is obsolete , it works!

No Comments

Friday links 124

  1. 20 Hilarious Programming Jargon Phrases You Should Know When Talking To Engineers – Business Insider
  2. Serving external traffic with WebMatrix Beta : Vaidy’s IIS Blog : The Official Microsoft IIS Site
  3. Accessing an IIS Express site from a remote computer — Johan Driessen’s blog
  4. 9 filme IMPRESIONANTE care îți pot schimba modul în care vezi lumea (VIDEO)
  5. The Salesforce Platform: The Return of the Citizen Programmer
  6. Introducing .NET Core – .NET Blog – Site Home – MSDN Blogs
  7. How Can I Advertise My Business For Free |
  8. 15 Amazingly Useful Google Services You Should Know About
No Comments

IndieGoGo campaign for programmer tools

 

I have made a campaign on IndieGogo for making a website,  videos and tutorials about C# and .NET tools and common practices. Think about  verticals( logging, security) that every application needs to have.

It will be a common knowledge base(book, video and website , and mobile application ) about how to use those applications.

Please join at  bit.ly/toolsProgrammers 

Thank you

No Comments