Tuesday, February 26, 2013

Streaming iTunes to Xbox 360

Our family has a Mac Mini and we put all our media in iTunes. We also have an Xbox 360. While iTunes is great for streaming media to another Apple device, I was also looking for a way to stream it to the Xbox, so that we can listen to our music and watch our home videos on our TV.

All the solutions I found on the web requires either installing another piece of software (Connect360) or hooking up another device (AppleTV), neither of which is very attractive to me.

As it happens, I also run Parallels on the Mac in order to run some Windows applications, and I hit upon this solution, which I did not see described elsewhere.

On Windows in Parallels, follow these steps:
  1. With Windows shut down, make sure that Parallels's networking is configured as a "Bridge Network" using the "Default Adapter".
  2. Start Windows and then start Windows Media Player (WMP).
  3. In WMP, select View > Library from the menu. Then, under the Stream secondary toolbar menu, select "Turn on home media streaming". If it is already turned on, be sure that "Automatically allow devices to play my media" is checked.
  4. In WMP, right click Music and select "Organize Music Library". Ensure that your Mac's Music folder has been added. This will be "\\psf\Home\Music". Do the same for Videos and Pictures. For Videos, you may also want to add your iTunes Media, which is located in "\\psf\Home\Music\iTunes\iTunes Media".
On the Xbox, follow these steps:
  1. Turn on the console.
  2. After the console starts, press the "Guide" button on your controller. The "Guide" button is the silver button with the lighted X on it.
  3. When the dialog box shows up, use the left "Stick" to select the "Media" pane. Wait a few moment for it to find your computer, then select your computer.
  4. Pick "System Video Player" or "System Music Player" depending on the type of media you want to play.
  5. Navigate to the video or music and select to play.

Note that I have only tried this with Windows 7 and Windows Media Player 12. I am running Parallels with 2 GB  RAM on a Mac Mini with a 2.3 GHz i5 and 8 GB of physical memory. With this configuration, everything seems to stream smoothly with no stutter.

Reference

Monday, February 25, 2013

Exposing IQueryable from a Repository

During my hiatus of 2-1/2 years from this blog, I have gone from independent consulting through being employed by a large company to now working for small company. Along the way, I have picked up C#, .NET and other interesting artifacts of the computing world. For that reason, I am expanding my blog to cover not just Java, but any computing topics that sparks my interest at that moment.

Recently, I was asked for my opinion on this C#/LINQ subject: Are there is any downside to returning IQueryable from a Get in a Repository pattern? That question forced me to put my thoughts on the subject in order, which I am setting down here.

Now, I know that purists hate it because it violates the “Separation of Concerns” principle. And there are good (and practical) reasons to be wary:
  • Since IQueryable is an expression container, the programmer may potentially construct an ill-advised query (e.g., adding a filter on an un-indexed field or pulling in a large table in its entirety.)
  • It may make it harder to unit test since IQueryable has a trail leading all the way to the database. This may be alleviated by mocking the data source, but may not produce the same results.
On the other hand, there is also a huge upside, if you need it:
  • Paging. Because you are deferring execution to the database, you can let the database pull in only the exact number of records you need at the point where you need it – in the Controller. Much more efficient than pulling it all into memory and then paging in code. I’d argue that this, in fact, promotes the SoC principle by keeping paging in View-Controller where it properly belongs, instead of passing it along through the business layer into the repository for handling. (One way around this is to encapsulate IQueryable. I am not particularly keen on this but I can't quite put my finger on why.)
Looking on the web, it looks like I may be late to the game as this topic has been argued many times with people's opinions falling on both sides.


References