Find examples of code, tutorials, and walkthroughs! When discussing programming and software engineering topics, examples are critical!

Fragments: Creating a Tabbed Android User Interface

Fragments: A Little Background Update: The actual application is available on the Google Play store. Once upon a time, Android developers used only two things called activities and views in order to create their user interfaces. If you're like me and you come from a desktop programming environment, an Activity is sort of like a form or a window. Except it's more like a controller for one of these classes. With that analogy in place, a view is then similar to a control. It's the visual part you're interacting with as a user. I remember the learning curve being pretty steep for me being so stuck in my desktop (C# and WPF) development, but once I came up with these analogies on my own, it seemed pretty obvious. So to make an Android application, one would simply put some views together…

4 Comments

Dynamic Programming with Python and C#

Previously, I was expressing how excited I was when I discovered Python, C#, and Visual Studio integration. I wanted to save a couple examples regarding dynamic code for a follow up article... and here it is! (And yes... there is code you can copy and paste or download). EDIT: Wait! Before you head to far, you might want to check out this more recent article on Python and C#! What does it mean to be dynamic? As with most things, wikipedia provides a great start. Essentially, much of the work done for type checking and signatures is performed at runtime for a dynamic language. This could mean that you can write code that calls a non-existent method and you wont get any compilation errors. However, once execution hits that line of code, you might get an exception thrown. This Stack…

6 Comments

Events: Demystifying Common Memory Leaks

Background If you've poked through my previous postings, you'll probably notice that I love using events when I program. If I can find a reason to use an event, I probably will. I think they're a great tool that can really help you with designing your architectures, but there are certainly some common problems people run into when they use events. The one I want to address today has to do with memory leaks. That's right. I said it. Memory leaks in your .NET application. Just because it's a managed language doesn't mean your code can't be leaking memory! And now that I've got your attention, let's see how events might be causing some leakage in your application. (There is source that you can download and run. Check the summary section at the end!) Instance-Scope Event Handlers One of the…

4 Comments

Simple Way To Structure Threads For Control

BackgroundI've previously discussed the differences between the BackgroundWorker and Thread classes, but I figured it would be useful to touch on some code. I'd like to share the pattern I commonly use when creating threads in C# and discuss some of the highlights.The Single ThreadI like to use this design when I have a single thread I need to run and in the context of my object responsible for running the thread, I do mean having a single thread. Of course, you could have your object in control of multiple threads as long as you repeat this design pattern for each of them.Here's the interface that I'll be using for all of the examples: internal interface IThreadRunner { #region Exposed Members void Start(); void Stop(); #endregion }Behold! internal class SingleThreadRunner : IThreadRunner { #region Fields private readonly object _threadLock; private…

0 Comments

End of content

No more pages to load