Posts Tagged ‘programming’

I originally posted this as a LinkedIn contribution. Making sure you can read it on my blog 😀

If it’s your first programming language, the language itself doesn’t matter. It’s the thought process that counts. The training to:

  • think logically,
  • break a problem or process into its component parts, and
  • understanding how those parts intermingle.

If you’re just looking to learn another programming language, you don’t need to spend money. There are FANTASTIC free tutorials out there. Check out Microsoft Learn https://learn.microsoft.com/en-us/training/ as a good starting point. You can follow entire tracks, or just one-off topics. There are videos, code examples, coding environments, tips and tricks, and more. To be fair, MS Learn is not the only option, but I only have 750 characters and you have a search engine.

I recently enjoyed a “fireside chat” at the Indy .NET Consortium, a meetup I run for local .NET developers.

I’ve had some good conversations with interns and others recently who have struggled with or had insights into this transition. My experience as a young developer was a bit different, because I didn’t take the traditional path of high school -> college -> workforce. Mine was high school -> college -> co-op -> left-school to work and create career -> go back to school -> leave school to work again -> work for startup -> work for consulting firm -> start a business -> shut down business and go back to workforce.

Our October 5 meetup talked about how the traditional path can be a bit jarring. The way I explained it to my employees was “In school, you can get an A, B, C, D, or F. And that’s OK. You learn from it. But in the workforce, you either get an A or an F. You can have as many Fs as you want, as long as you end up with an A. Sometimes, within reason, I’ll accept an A- or B+, but it’s rare. We’re paid to deliver, not pass lessons.”

You can watch the entire discussion below:

A friend reached out today and asked “Hey, I need my splash screen to be themed based on whether Dark Mode is selected on the Android device.” I had never done that before, so I was curious how it should be done.

Dark Mode is new to Android 10, a.k.a. Android Q. Not as tasty, but hey, gotta ship something. It has a range of benefits, such as lower energy consumption, looking cool, and frustrating developers without budget for theme-aware apps.

It turns out, after some sleuthing, it’s relatively straightforward.

First, this article assumes you’re following the “splash screen as a theme” approach, which you can learn more about here. The example is for Xamarin.Forms, but the same approach applies to regular Android development.

Basically, you have a “splashscreen” style, and you set it as your app’s theme in the Android manifest. Then, you “swap” to the real theme in MainActivity. For example, what I use in an app, located in resources/values/styles.xml:

  <!-- Splash screen style -->   <style name="splashscreen" parent="Theme.AppCompat.DayNight">     <item name="android:windowBackground">@drawable/splash</item>     <item name="android:windowNoTitle">true</item>     <item name="android:windowIsTranslucent">false</item>     <item name="android:windowIsFloating">false</item>     <item name="android:backgroundDimEnabled">true</item>   </style>

Note my drawable. I want a different drawable for my dark vs. light (normal) theme. Here’s what is different:

  • The parent is now Theme.AppCompat.DayNight
  • I’ve added a different set of drawable folders for the Dark theme images. These are the same folder names, with -night appended to the end:

different drawable-night folders

In this example, I haven’t yet added the other folder variations, but you get the point.

The theme swap code in MainActivity is as follows:

protected override void OnCreate(Bundle savedInstanceState)
{     TabLayoutResource = Resource.Layout.Tabbar;     ToolbarResource = Resource.Layout.Toolbar;     // Swap back to the normal app theme. We used Splash so we didn't have to create a special activity.      // Cute hack, and better approach.     // Idea from URL: https://xamarinhelp.com/creating-splash-screen-xamarin-forms/     Window.RequestFeature(WindowFeatures.ActionBar);     SetTheme(Resource.Style.MainTheme);

That’s all there is to it. If Dark mode is enabled, the splash.png from the -night folder will be used, otherwise the normal image will takes its rightful place.

If you have any questions, please hit me up in the comments.

Special thanks to this StackOverflow article for the –night hint.

More info on Android Dark Theme can be found here.

I recently read a “Coding Question” thread, and a developer was asking what we all thought about this article. I wanted to hold on to my replies, so I’m posting it here for posterity 🙂

Auri:

Only a Sith deals in absolutes. There are use cases for everything, with exceptions.

Auri:

Seriously, though, I’d write tests to ensure the states that you want work as expected.

Auri:

And now that I’ve had my coffee:

Exceptions are a necessary construct. If something doesn’t go as planned, we need a way to handle it. In his article, he’s against blindly swallowing exceptions. That’s generally sound advice. Ask yourself: “Is this an expected exception? If so, do I have a specific exception handler for it, or am I just using the generic catch-all? Have other exceptions occurred? If so, is this one expected? Didn’t I read about C# support for exception switch statements? Did I just shiver?”

Like I was explaining before, only a Sith deals in absolutes. The way I see it, if an error is unexpected, I should have specific use cases for how to handle that exception. I should, generally, never blindly swallow with no logging, or simply re-throw and assume the code above will address. At least, not without a custom/known/non-generic exception I can check up the chain, or include in an integration test. Good article about testing [written by a friend] here, btw: https://arktronic.com/weblog/2015-11-01/automated-software-testing-part-1-reasoning/
At the very least, and I try to follow this rule as much as possible, LOG in any exception for tracking and pro-active/offensive development. Better that you can read logs, or run scripts to let you know about exceptions, and help things go right, than to be blind with a “well, the code seems to work, so let it be” approach. That’s the key goal, really: Help things go right. There are exceptions [heh] to this rule, like simple utility apps whose job is to bulk process data, and exceptions are part of the game. Still, I try to make sure to log, even with those. Unexpected/unintended bugs tend to appear when you’re dealing with massive amounts of data, and logs give a perspective you can’t see from debugging.
Ok, next cup of coffee.

CEATEC, the Combined Electronics and Technology exhibition in Makuhari, Japan is this week. The latest innovations from Japanese companies are showcased here, often many months before Americans get a taste. I’ll be posting a reporter’s notebook in a bit. For now, enjoy clicking through videos and photos of cool things found on the show floor!

Panasonic’s Cocotto Children’s Companion Robot

Bowing Vision Violin Improvement Sensors & App

Hitachi Robot for the Elderly, and those with Dimentia

Omron “Ping Pong” Robot, Now with “Smash” Shot Abilities

au’s AR Climbing Wall

Unisys’ Manufacturing Robot That Follows Lines

VR Racer

Takara Tomy Programmable Robot

Dry Ice Locomotion

Airline Customer Service Bot Attendant

Feel the Biker’s Heartbeat

Wind Sensors Paired with Fun Animations

The Trouble with Tribbles – Qoobo Robot

Spider-Like Robot from Bandai

Semi-Transparent Display with Water Effect

Bandai BN Bot

Model Train

Kunshan Plasma

The Many Faces of Robots at CEATEC

There were MANY robots at CEATEC. Many just sit there and answer basic questions. Still, some, like Omron’s Ping Pong robot, can learn and adapt and make a difference.

 

Micro Adventure was a series books in the 1980s where you had to write computer programs to get from chapter to chapter. It was a great way to learn coding for a geeky kid looking for a good story related to computers. A few months ago, I was granted rights to use the books on a website, and now it’s in beta! Check out the site and let me know what you think!

https://microadventure.net

 

Want to learn all about Xamarin and how you can use it, while not spending most of your time watching code scroll by in a video? I figured there was room for an explainer without being a close-captioner for a code tutorial. Enjoy my latest video!

https://www.youtube.com/edit?video_id=AhvofyQCrhw

From the description, along with links:

Have you been considering Xamarin for your cross-platform mobile app? This presentation will help.

In this non-code-heavy presentation, we’ll discuss:

* What is Xamarin
* Development Environment Gotchas
* Creating a Sample To Do List App without writing any code
* Reviewing a real Xamarin app that’s “in the wild”
* Review native, platform-specific integrations
* Discuss gotchas when using Xamarin, and mobile apps in general
* Answer audience questions

Why not code-heavy? Because there are many examples you can follow online. This presentation will provide valuable information you can consider while reviewing the myriad of tutorials available to you with a simple Bing or Google search, or visiting Pluralsight, Microsoft Virtual Academy, or Xamarin University.

If you have any feedback, please leave in the comments, or ask me on Twitter: @Auri

Here are the links relevant for this presentation:

Slides: https://1drv.ms/p/s!AmKBMqPeeM_1-Zd7Y…

Indy.Code Slides with Cost and Performance Figures: https://1drv.ms/p/s!AmKBMqPeeM_1-JZR4…
(you can find the Indy.Code() presentation on my YouTube channel)

Google Xamarin vs. Native iOS with Swift/Objective C vs. Android with Java Performance Article: https://medium.com/@harrycheung/mobil…

Example code for push notifications, OAuth Twitter/Facebook/Google authentication, and more: https://github.com/codemillmatt/confe…

Link to Microsoft Dev Essentials for $30/month free Azure credit and free Xamarin training: https://aka.ms/devessentials

Microsoft Virtual Academy Multi-Threading Series: https://mva.microsoft.com/en-us/train…

 

I’m continuing my resolution to record as many of my programming and technical presentations as possible. I recently spoke at the inaugural Indy.Code() conference. It was excellent, with an incredible speaker line-up. I hope they, too, post some of their presentations online!

Watch the Video on YouTube

From the synopsis:

Should you write your app “native” or use a “cross-platform” solution like React Native, Xamarin, or NativeScript? The new wave of native-cross-compiling solutions provide significant cost savings, code reuse opportunities, and lower technical debt. Does wholly native, per platform development, still play a role in future mobile development? Let’s discuss together.

In this presentation, we’ll discuss:

  • The growth of native, hybrid, and cross-platform mobile development solutions
  • Cost analysis of multiple native and cross-platform apps
  • Considerations for each native and cross-platform solution
  • Lessons learned

Slides are available here: https://t.co/5iLhEoEfen

If you have any questions, I’m happy to answer them! Please email me or ask on Twitter.

 

I’ve noticed students feel learning object oriented programming appears tough when first exposed to structured development practices. To add insult to injury, boring example relationships like “people” and “students” and even types of fruit and their plant family relationships are used to show how objects relate to each other. I’m more in the camp believing learning “scary” new concepts should be fun, even memorable. People tend to remember good jokes, and forget dull experiences. I experimented with an approach to OOP. I used the old children’s storybook, Everybody POOPs.

We’re all human beings. All Humans eat and drink, and everybody poops. It takes a system to get to the pooping stage. We also fart. Adults fart and say excuse me!, while children fart and giggle. They’re still Human. Hopefully you can see how these related entities can be turned into computer classes.

I finally got around to recording a video of my teaching this concept, as it relates to classes in Microsoft’s C#. Student reactions are always enjoyable. Most of the time, they laugh, and have fun. I usually get compliments that it’s a lot easier to remember because it’s funny. Some people are disgusted I would talk about such a topic in class – I’m thinking those people don’t have a sense of humor. No photos are involved, so what’s the big deal?

Watch the Video

Here’s my original Blog Post about it

I was challenged last year to write a JavaScript version of Everybody Poops. I finally got around to that this year, explaining objects to students at the TeKY Initiative. That was a bit tougher, since JavaScript isn’t really object oriented. Still, it was fun. The students even got me a poop emoji mug 🙂 You can view the code here. You’ll need to use the console to play with the object.

I’m continuing to teach concepts in [what I feel are] fun, real world ways. My first step has been to create “Real World Programming” videos on YouTube. Two are complete as of this article – OOP (link above) and Inversion of Control + Dependency Injection. I hope to do a few more in 2017 as time permits. If you have a suggestion, please let me know!

I’ve been using this example for a couple years now – explaining Object Oriented Programming with a cute example based on the book Everybody Poops. It’s fun, and much less bland than the other OOP examples I’ve seen 🙂

Here’s the link: https://www.youtube.com/watch?v=_0PFHaX04mo

In case you missed the first video on Inversion of Control and Dependency Injection: https://www.youtube.com/watch?v=HcJN1XCs8t0

This is the second video in my Real World Programmer series. I hope you enjoy!