.NET Maui Preview 3

Is here! Read David Ortinau’s blogpost

Posted in Essentials | Leave a comment

C For Fun

Old but gold…

/*
 * find the important things in Life, the Universe, and Everything
 */

typedef short	some;		/* some things are short */
typedef some	very;		/* some things are very short */

#define A			/* The first letter of the English Alphabet */
#define LINE	2		/* 2 points define a line */

#define TRUTH	BEAUTY		/* truth is beauty */
#define BEAUTY	10		/* and beauty is a 10 */

#define bad	char		/* burnt on both sides */
#define old	char		/* the great Chicago Fire */

#define	get	strlen		/* during your life, try to get some sterling */
#define youmake	float		/* you make it, I'll drink it */


#define		yourgoals	in terms you can understand
/*
#include	"yourdreams"	/* for the future */


	/* everyone needs goals */

short	term;
double	yourpleasure();
double	yourfun;

long	Term, play(), agame;

	/* everyone needs diversions */

old *joke = "Why did the chicken cross the road?\n\tTo get to the other side!\n\t\tWocka Wocka Wocka!\n";
	

tell(joke)
bad	*joke;		/* wait- you haven't heard it yet! */
{
	short laugh;	/* please */

	laugh = get(joke);
	write(1, joke, laugh);	/* write it down- don't say it */

}

	/* most folks like music */

long play(record)
long record;
{
	very pleasant = TRUTH;		/* if you like music */

	while (record == pleasant)
		play(record--);

	return( pleasant );		/* music soothes the savage */
}


double	yourpleasure(one, way)		/* this is necessary if */
some	one;				/* is watching ,or if you have a */
long	way;				/* to go  */
{
		/* this can change one while maintaining one's identity */
	one = one * one;
	return( one );		/* after all, it should have at least doubled */
}

hold(temper)			/* good advice */
A short temper;			/* is a dangerous thing */
{
	A long	time;		/* is what you need */
	very calm;		/* is how you should be */

	calm = temper, temper;

	while (calm--)
		wait(&time);

	return(calm);		/* if possible */
}


	/* now, on to the main thing */

main(thing, mustbe)		/* to balance work, play, and goals */
some thing, mustbe;		/* important, or we wouldn't be here */
{

	long	time();		/* know C */
	very	bored;		/* the result of too few goals */

	short	hours;		/* make */
	long	yourwork;	/* which makes for */
	short	tempers;	/* which can be improved by */
	long	laughing;


	/* first, set priorities */
	yourwork = 0;
	yourfun = 1.0e+38;

	if (yourpleasure( mustbe, yourwork ))
		yourfun = yourwork;
	else
		yourfun = play( agame );

	bored = yourfun - yourwork;  	/* nothing to do? */
					/* reach out and touch someone! */

	switch ( bored ) {	/* connects all of this together */
	default:
		hours = hold(LINE); /* no way to avoid it, take a */
		break;
	}

		/* take a music break */
	while ( thing-- ) {	/* you make my heart sing */
		youmake everything;
		very groovy;
	}

		/* focus on what is important to you */
	while ( yourfun < 0 ) {
		yourpleasure( mustbe, agame);
		yourfun = play( agame );
	}

	tell(joke);

	exit( laughing );
}
Posted in C, Essentials | Tagged | Comments Off on C For Fun

Jon Galloway on Visual Studio Mac

Jon joins us again, this time to talk about Visual Studio Mac and Maui!

Posted in Essentials, Mac, Maui, Visual Studio | Tagged | Comments Off on Jon Galloway on Visual Studio Mac

Resume

Posted in Essentials | Comments Off on Resume

Xamarin Best Practices

In a recent blog post, I showed the C# best practices we use at my current placement. Today, the Xamarin best practices:

Xamarin 🐒 Best Practices

The Do’s 🙌

👍 Catch XAML Errors Early

Add the following attribute to code behind in order to improve performance and catch xaml errors early.

[assembly: XamlCompilation (XamlCompilationOptions.Compile)]

Why: https://stackoverflow.com/questions/46338575/bad-xaml-still-compiles-with-no-error-then-runtime-error-occurs-in-xamarin-form/46338664 

Continue reading
Posted in Essentials | Comments Off on Xamarin Best Practices

C# Coding Standards – Updated

Let’s face it, most coding standards are arbitrary. The key to a successful project, however, is not which standards you follow, but that you are consistent.

Here is a partial list of the C# coding standards my team uses and advocates, updated by what we’ve learned in the past year.

Most of these are industry-wide conventions and thus using them will ensure that your code is easily readable by people who are not you. (Many thanks to Adam for letting me post this here)

👍 use PascalCasing for class names and method names.

public class ClientActivity 
{ 
    public void ClearStatistics() 
    { 
        //... 
    } 

    public void CalculateStatistics() 
    { 
        //... 
    } 
} 

Why: consistent with the Microsoft’s .NET Framework and easy to read.

👍 use camelCasing for method arguments and local variables.

public class UserLog 
{ 
   public void Add(LogEvent logEvent) 
   { 
    var itemCount = logEvent.Items.Count; 

    // ... 
   } 
} 

Why: consistent with the Microsoft’s .NET Framework and easy to read.

Continue reading
Posted in C#, C# 8, C# 9 | Comments Off on C# Coding Standards – Updated

Mads Torgersen! C# 9 & Beyond

Microsoft’s Mads Torgersen– Lead Designer of C# — talks about how to know when to use the new features in C# 8 and 9, and more.

Posted in C#, C# 9, Essentials | Tagged | Comments Off on Mads Torgersen! C# 9 & Beyond

Covid, False Positives & Bayesian Probability

This is a repost from 2009. It talks about breast cancer, but applies equally well to Covid testing, given the high percentage of false positives (not to mention the more worrisome false negatives). We simply are not wired well for probability…

Yudkowsky poses the following canonical problem:

1% of women at age forty who participate in routine screening have breast cancer. 80% of women with breast cancer will get positive mammographies. 9.6% of women without breast cancer will also get positive mammographies.

Continue reading
Posted in Essentials | Comments Off on Covid, False Positives & Bayesian Probability

New site for my writing

I’ve created a site for my non-technical writing. Check it out.

Posted in Essentials | Comments Off on New site for my writing

.NET Maui!!!

Check out this lineup of guests

What can I say… an hour of amazing Maui goodness, including:

  • What is Maui?
  • When is Maui?
  • How does it affect Xamarin.Forms?

Posted in Maui, Xamarin.Forms | Tagged | Comments Off on .NET Maui!!!

MonkeyCache step by step

The amazing James Montemagno of Xamarin/Microsoft has done it again. He has created an incredibly simple cache, named MonkeyCache, that you can get up and running very quickly.

In this post I will walk through setting up and using the cache, step by step.

Continue reading
Posted in Essentials | Tagged , | Comments Off on MonkeyCache step by step

DataTemplateSelector

Suppose you have a collection of items and you want to display them in a ListView (Xamarin.Forms). The catch is that you want to change the display of each item depending on its state or some other code-based attributes.

At first glance this would seem very difficult, and you’d have to modify the instances in the collection to do so. This is where the DataTemplateSelector comes in.

In short, you create two or more data templates — one for each way you might want to display one of the items in your collection — and then you tell Xamarin.Forms, by way of the DataTemplateSelector, which data template to use.

Continue reading
Posted in Essentials, Xamarin.Forms | Comments Off on DataTemplateSelector