0 as a macro for successful result?

For more than 20 years, I’ve worked on/with many libraries and frameworks.
There are many oddities. Some were understandable, while others were clearly by wrong design.

However, for recent 10 years, many of such oddities were gone in many frameworks, libraries.
But still I see some.

Most recent one is to define 0 for meaning successful result and -1 or even 1 to mean failure.
As far as I remember, I saw such definition about 20 years ago in Microsoft header file.
For the recent 10 years, many of coding style became like this :

isSuccessful = DoSomething();
if( isSuccessful ) {

}

if a macro value for meaning success is 0 ( as a return value for DoSomething() ), writing code like above will fail.
So, it should be always like :

if( isSuccessful == T_SUCCESS) {

}

However, the naming the value as ‘isSuccessul’ is not really useful.
In 80’s and 90’s people tended to declare such variable name like ‘result”.

STATUS result = DoSomething();
if( result == T_SUCCESS) {

}

So, defining a successful value as 0 doesn’t match current style and even in 90’s style it is good only partially.
Actually even in 80’s and 90’s such values were set 1 or none-0. Failures were set 0, and -1 in some libraries.
Because 0 is implicitly evaluated as false and none-0s are true, it’s common sense to define some SUCCESS as 1 or non-0, and Failure as 0.

So, whether to follow 80’s and 90’s convention or contemporary convention, it’s very odd to define 0 as SUCCESS.

I wonder what people thought when they design it such a way.

Does Windows 10 still have ‘start screen’?

On most PC tech magazines and tech blogs, they say Windows 10 brought Start menu back and got rid of ‘Start Screen’.

However, actually the answer should be ‘Yes’ and ‘No’.
Most English-speaking people I have met so far tend to consider only surface of issues, not the implication of an issue or another aspects under the surface.
I know what kind of answer they want. But if I just answer so, I know that they will not understand things correctly. On the other hands, Koreans ( not current young generations, but till the generation I’m in ) tend to understand by applying individual case which is mentioned in broader way. In other words, if one things is explained, Koreans tend to apply it for broader case and tries to figure out if it can be true for that broadened case. Then they find the optimal boundary where it can be applied.

Back to the Windows 10 stuff..
The Start menu have integrated Start Screen. So, depending on how you see it, you can say it’s still there or there is no Start Screen.

Start menu and integrated Start screen

Start menu and integrated Start screen

There is another aspect.
On desktop, you can set “Tablet mode” forcefully.
Then the Start Screen appears like Windows 8.x.

Changing to tablet mode

Changing to tablet mode

 

Resurrected Start screen

Resurrected Start screen

However, the reason MS brought its Start menu back in Windows 10 and thus put the precedence of Start Screen backward is that users complaint about the awkwardness of Start screen on desktop and inconvenience of not having Start menu.
So, I don’t think there will be more people to turn on tablet mode on desktop environment.
So, although the Start Screen is there, it will be more rational to say “there is no Start Screen” for most users.

Probably it’s the reason most magazines and blogs for PCs describe that Windows 10 ( for desktop ) don’t have Start Screen and superseded by new Start menu on steroid.

Android UI problem

Android Kitkat has very confusing UI. Actually, Android UI has been like this so far.


There is a ‘turn around’ button on the bottom. it means “Go back”.
However, on top of the screen there is also ‘<‘ button. Usually there was so-called a hamburger button.

Both means “Go back”. However, there is difference where it goes back. The bottom one goes back to its immediate previous screen, while the top one goes way back to a list screen.
Probably from there different view controller was spawned ( if using iOS terminology )

Isn’t it confusing?

Can’t Android Studio 1.0.1 find your JDK?

Well, as usual, I tried the latest Android toolset again.
I’ve used Eclipse with ADT so far and tried Android Studio a while ago.

However, it looks to me that Google put Android Studio in front of Eclipse.
That sounds like Android Studio is good enough to use. So, I decided to try it.
(Although I’ve used Eclipse for long time, I don’t like it. People who say Eclipse in favor say so because Eclipse has many good features. However, how to glue all of them is not good with Eclipse. Eclipse is all-round tool. I’ve used it with some VHDL open source compiler, have used for long time for C/C++ project on Linux and for Makefile analyzer on Windows. Because it has all functionality with help of plugins, it’s not good at anything. (each functionality is the best. But again, how to glue them are not good. If you don’t understand what I’m saying, try to open some sample project for Android. What’s weird is that you need to choose “Create” for opening a project. )

Anyway.. again.. I’m disappointed with Android Studio in terms of the 1st experience.
It couldn’t find where the latest JDK was installed and couldn’t find its matching VM.
Well, JDK is made by Sun/Oracle. So, there is such discrepancy. However, at least, Google people could make some “Read Me First” popping up after being installed and guide a user to configure any further setup.
However, it just displayed “Can’t find a matching VM.”

Ok.. I know that many GUI programs print out something when being launched from a terminal. So, I did it. It complaint that STUDIO_JDK environment variable is empty. Hmm.. it looks like it should point to where JDK is installed. But shouldn’t it be JAVA_HOME? After looking up Google, some said it could be solved by setting JAVA_HOME. But no luck. It may have been true with older Android Studio. (Well, currently one is 1.0.1 version, though.) So, I directly set up STUDIO_JDK from console like this.

export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk

And launched with : open /Applications/Android\ Studio.app

It worked!

Hey.. Google people! Why don’t you guys make the 1st experience with Android Studio better? You have some competition ( from MS with Visual Studio 2015, although theirs is based on Mono. )

c.f. http://tools.android.com/tech-docs/configuration/osx-jdk

A way to get out of the squirrel treadwheel

I was trying to figure out how to create ID2D1Bitmap1 instance which is to be mapped to memory region. But I found out that MSDN documentation put me in self-repeating cycle ( so, I call it squirrel treadwheel. ). In on document it says, the options can’t be used for bitmap instance created with ID2D1DeviceContext, while on the other page, the device context is to be used to create ID2D1Bitmap.

I posted this to MSDN page, ID2D1Bitmap1::Map page.


 

“These flags will be not be able to be used on bitmaps created by the ID2D1DeviceContext”

However on this “ID2D1Bitmap1 interface” page, it says :

Creating ID2D1Bitmap Objects

Use one of these methods to create an ID2D1Bitmap object.

ID2D1DeviceContext::CreateBitmap
ID2D1DeviceContext::CreateBitmapFromWicBitmap

It’s a squirrel’s wheelmill. Don’t you think so?
( this flags can’t be created by ID2D1DeviceContext => on other page, ID2D1Bitmap1 is created using those device context.)

Moreover, throughout Direct2D/DirectWrite and related technology pages, it’s not clear whether methods/functions returns using a parent class pointer ( like ID2D1Bitmap *) can actually return one for its child class instance like ID2D1Bitmap1. By trial and error, I found out that it’s strictly for the stated class. It’s better to be documented. ( Especially you guys are aware of that C++ has supported late binding.)

Secondly, for this issue on how to create ID2D1Bitmap1 with D2D1_MAP_OPTIONS_READ, and thus D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ specified in creating an instance of ID2D1Bitmap1, I found some answer here.

The post marked as “Answers”, he created an instance of ID2D1Bitmap1 using CreateBitmap() method of ID2D1DeviceContenxt. It’s opposite to what is mentioned on this page. ( for your convenience, I put it on the top. This document clearly said “These flags will not be able to be used on bitmaps created by ID2D1DeviceContext.” ) You can see that the ID2D1Bitmap1 is created using the device context’s CreateBitmap() method, and it has CPU_READ and CANNOT_DRAW option, and when Map() is called, D2D1_MAP_OPTIONS_READ is specified.

I will test this. But because people marked it as an “Answer”, I sort of believe that it works.

MSDN document is a squirrel treadwheel

D2D1_MAP_OPTIONS enumeration states that D2D1_MAP_OPTIONS_READ is not available on bitmaps created by ID2D1DeviceContext. Then, to figure out how to create ID2D1Bitmap1, which Map() can be used for, if we visit to ID2D1Bitmap1 interface page, it says “use one of these methods to create and ID2D1Bitmap object.

ID2D1DeviceContext::CreateBitmap
ID2D1DeviceContext::CreateBitmapFromWicBitmap

Didn’t it say that D2D1_MAP_OPTIONS_READ is not available for bitamps created by ID2D1DeviceContext?

Shouldn’t there be more way to create ID2D1Bitmap1?
Since 1990, MSDN document has never been good. However, after they adopted “community-based documentation” model, it became even worse. For example, some pages contain just meaningless vague information. Some pages contain sentences which can be understood in many different ways…

Come on, Microsoft people! What are you guys thinking about? Do you guys really think the MSDN document is good?
It’s also creating ID2D1Bitmap1 by “ID2D1DeviceContext”.

ID2D1*RenderTarget & Device/Device Context

Rendering with Direct2D on Windows 8

On Windows 7 and earlier, you use a ID2D1HwndRenderTarget or another render target interface to render to a window or surface. Starting with Windows 8, we do not recommend rendering by using methods that rely on interfaces like ID2D1HwndRenderTarget because they won’t work with Windows Store apps. You can use a device context to render to an Hwnd if you want to make a desktop app and still take advantage of the device context’s additional features. However, the device context is required to render content in a Windows Store apps with Direct2D.

  •  Windows 7 and earlier : ID2D1*RenderTarget are expected to be used to render drawing primitives/text etc.
  • Windows 8+ : Device context are expected to be used, because those ID2D1*RenderTargets don’t work for Windows Store apps.

Question 1: Why are classes/interfaces for drawing affected by Windows Store? Technically Windows Store is for selling S/W. They may require some, but is there any valid reason to prevent some drawing classes/interfaces from being used?

Question 2: If it’s that critical, shouldn’t there be any warning message on ID2D1*RenderTarget MSDN pages, at least on their 1st page?

Question 3: So, if you are not going to sell your S/W on Windows store infrastructure, you don’t have those restrictions, right? (Anyway Windows store doesn’t look to draw people’s attention as much as Apple’s app store. So, it will not serve as “People, you don’t know where to find your Windows app, come here!” role.

 

Follow

Get every new post delivered to your Inbox.

Join 44 other followers

%d bloggers like this: