Windows Reflection vs. Parent handling of background color for Windows widgets ( MFC )

With MFC, to paint the background of a controls or widgets, you can override OnPaint(), but there is another mechanism in that the parent object of a control provides background color for the control.

That is to make the parent respond to WM_CTLCOLOR or one of its variants, but in MFC 4.0 ( which is already pretty old ) provides more expanded functionality of that. It’s called Message Reflection. With Message Reflection, interested messages can be handled by the child control windows as well as the parent windows.

TN062: Message Reflection for Windows Controls
NOTE : Ok. Here is another example I think the MFC engineering team did wrong.

When we say “Window”, it means “Window”. However, in Win32/MFC terminology, it can mean other controls/widgets.
For example, if you want to set a text of a CEdit, you call CEditInstance->SetWindowText().

It’s not to change the “title bar text” of the window. It’s to set text of the CEdit. Why is it designed as such?
Well, there are two different classes in MFC, i.e. CWindow and CWnd. CWindow is for “Window” which we know generally. CWnd is a parent class of any visual elements or Widgets in MFC space. However, as the class name implies, we, long time windows programmers, tended to mention that as a class for window.
So, there is nomenclature problem. There are many wrong doing in design of MFC. If compared to that of .NET or Cocoa, we can see how poorly MFC was designed.
I hope MS someday fixes all the problems of MFC, but I doubt if it would happen, because they nowadays concentrate more on C#/.NET ( not even C++/.NET )
Well.. CLR is practically fast. That’s what most people, especially S/W engineers working for “business logic” think. Yeah.. they were Visual Basic or Java programmers. To their standard, they think CLR is very fast. To people like me, who have been hardcore native C/C++ programmers and someone who has a background in Computer Science, we don’t think so. Well.. more strictly speaking, we know that it’s practically fast. Probably most C++ programmers in their 20′s and 30′s nowadays are kind of new kids on the block to me, and they will not agree with me. However, in 80′ and 90′s we had agreed upon that.

 

 

WWDC 2013

wwdc13-about-mainWWDC 2013 ticker sale starts at April, 25th, 10 AM PDT

You would wonder if it’s worthy of the fee, $1,600. ( I hate it to say $1,599 )

So, here I would like to summarize why it can be good to attend and why it can’t be.

  • Why you should attend
    • You are surrounded by Apple haters and naysayers. So, you need motivation.
      • Until iPhone/iOS was announced, Mac developers were small group of cattle. You know Mac is very exciting platform due to its elegance of frameworks and many other stuffs, but you felt desperate because people around you say negative stuffs based on false information. At that time you need strong motivation. I can’t forget how amazing experience that was. ( I was a Windows/Unix developer also. So, mine will not as great as other Mac-only developers. Let’s say you developed only for Mac, how great the feeling could be! )
      • Even nowadays, although Apple is doing quite well, stock holders who worry that Apple’s margin on iOS devices are not as good as how it was before and journalists who don’t understand the whole picture, there are still many nay sayers. Check some tech. news web site recently. They even said Tim Cook should be kicked out. The low margin can be good for customers because we as customers can buy a good products in cheaper price. Also that makes Apple’s products more competitive. How single-cell creature-like thinking of that greedy stock holders!
      • So, you may still need motivation.
    • If you can speak English without worrying about your pronunciation and know how to start conversation with foreigners, it will give you a good feeling and may be able to find an opportunity in other country than you live. It doesn’t matter you emigrate to those foreign countries or not. At least you can get fresh and live information on markets you are interested in.
    • You can go through as many sessions as you can. If you do it at home with their sliders and video, you may not able to do that. I personally didn’t even watch those video except for a few selected ones.
    • If you take a MacBooks with you, you can attend their hand-on sessions. You can learn with Apple engineers’ help in a short distance. So, to make the learning process more effective, be prepared to be familiar with those code you want to write and technology behind it. Then you can ask more directly instead of focusing writing code in hand-on sessions. While asking questions and learning stuffs, you can also chat with Apple people and suggest your idea. You never know whom you are talking with. Actually I noticed that many people asked to those Apple engineers on what they do at Apple. Then you can directly approach those people who is responsible for technology you are interested and ask very specific questions. It will be very different from asking through their email list and discussion board with some stupid Apple-lover police living in the developer discussion board and those email list.
    • Nice meal and some kind of meet-up : Well, there are people who hate meal provided by Apple. True. Chefs prepared those in large quantity. So, it may be dried and taste like plastic. However, eating with birds with same feathers gives you good feeling.
    • Sample projects which shows how to use new frameworks or even older ones. Remember this. Sometimes this sample projects are not available for downloading for people who don’t attend WWDC. Sometimes they do. For WWDC 2012, they provided a link to download sample projects used in the WWDC 2012. But for WWDC 2011, they didn’t. I don’t know if they decided to post those for good since WWDC 2012. But let’s open a possibility that they may not post again for WWDC 2013.
  • Why it’s OK not to attend
    • The fee, $1600, plus fee for hotel, and probably for renting a car cost a lot. A LOT… It kills me.
    • The speakers may speak too fast for things you want to concentrate, and too slow for things you want to skip. They also flip slide pages as such.
    • Those sliders and video are available to any members of Apple Developer Membership. So, you can sit in front of your computer and watch and read it without paying the killing price. ( plus you can go to a bathroom by clicking “stop” button. )
    • You don’t need to persuade your manager who don’t understand why their S/W engineers need to be updated with new information.
    • Actually you may not learn anything just because you attend it. People are good at English can also say so. Anyway you have to figure out how to use interested framework methods and classes in the way you want. If you are non-English speaker, except for gathering with people who speak your mother tongue, WWDC can be boring. There is no our favorite pierrot any more. ( you know who he is. )

If the attendance fee is around $150~$300, I can make up my mind easily to attend. But $1600 + is kind of high for deciding.

This time I’d like to attend it. I feel like out of gas in developing S/W nowadays. Even on Windows, I had to confront who don’t understand S/W development. Those environment let me down. Developing S/W was joyful moment so far. However, here where I work, it’s discouraging.
Attending Apple-centric conference doesn’t cheer my Apple side only. It also cheers up my whole developers side in me. It doesn’t matter if it’s Windows, Web or Unix.
So, I value those “live” feeling that we are S/W developers a lot.

How about you? Are you going to attend WWDC 2013?

LLVM’s Clang Compiler Is Now C++11 Feature Complete

OK. Now C++11 is said to be fully implemented in LLVM.
Although I kept opening my eyes on LLVM/C++0x/11 and have checked what were added, changed, etc, but it looks like that it’s time to swallow it instead of tasting.

When Android frameworks are compared with Win32…

Just my little thoughts on Android…

Currently, I’m reading “Fragments” class document. I found out that it was pretty hard to follow, because the terminology Android developers ( not application developers, but the framework developers ) chose didn’t help to make it “self documented code”.

If someone insists me to compare how bad Android APIs are compared to Win32, I would say this.

When I put my hands on ToolBox API and Win32 API about 20+ years ago, I thought Win32 was designed very poorly compared to ToolBox.How bad Android is compared to Cocoa is much worse than how bad Win32 was compared to ToolBox.

Because Google people elected many not-sound-natural terminology and method / class names, it prevents from writing self-documented code.

Why haven’t Android app developers pointed those out?
Probably aren’t they interested in framework and API design itself? They are just busy to spit out Android apps?

Compared how it was about 20 years ago, it’s pretty hard to find any technical article on S/W architecture design for platforms popular in the market nowadays. ( Well.. nowadays tech. writing is done by journalists not S/W engineers… )

On April, 17, 2013, at AllThings D conference, MS head of Windows phone said,

“With Android … it’s kind of a mess,”

Well, he said iPhone is boring. But.. anyway I think he is right about Android. ( and I also agree with him about iPhone. )
Some people would say to Terry Myerson, the head of Windows phone, “Do your own business” or “How dare! Your Windows phone is not as successful as iPhone or Android phone!”.
But whether his Windows phone is successful or not, ( so thus whether he deserves to say that or not ) I think he pointed out the critical point of Android ( and iOS )
Nowadays S/W business is driven more by marketing and business, not by technology. So, whether a platform is bad or not, if it gathers some popularity in the market, people tend to rush into it.
I’m really sorry about it.

 

How to port an OS…

For my original intention of buying a Raspberry Pi

Thoughts on naming for some concept

Well, I know that many S/W engineers don’t care about naming for some concept. But naming is very important because it speaks for itself about what it is for, for what you can use it, and so on.
Because well-named terminology helps smooth flowing or transitioning across multiple related concepts, naming well helps a framework easier to understand and reduces human errors in applying those features represented by those terminologies for.

I’ve written code for more than 20 years. So far, I put my hands on many technologies, languages and frameworks from different companies.
Borland, Symantec, Apple, MS, IBM, and many other open source project organizations to name the few. So, I’m qualified to compare them.
However, consistently, it was only Apple which was good at that. More interestingly, when a company put some proper naming for their classes, architecture etc, how to use them was also easy and overall architecture was more well defined and refined.
I think it’s not coincidental. Once one has rigid and clear idea on a target concept, one can name it properly and design its architecture clearly.

I remember that I wrote about MS’s awkward naming on some of their technology a while ago.
Today, I’d like to take an example from Google.

I made up my mind to take a look at Android SDK more deeply to be able to write actual code ( not just read and understand code ) for Android.
While doing that I ran into a few odd names for their classes and architecture.
“Activity” and “Intention” are good examples.
While working for many companies, I noticed that people just pick function/method names with “noun” form. Do you know what’s wrong about it?
Method and functions are for “doing” or “action”. So, it’s better to have “verb” form. While variables are good to be in “noun” form.
By doing so, code you write starts to be “self-explanatory” or “self-documented”. And it can reduce human mistake in writing code.
Now, let’s pick “Activity”. What kind of feeling you get?
Isn’t it something like, “it’s for DOING something” not “what it is”, or “being”.
So, if it is to mean “event handler” or “transition between views” or “collection of methods to be executed”, it’s easier to memorize the concept of “Activity” and to use the memorized concept.
However, in Android terminology, it’s more about “things to be presented visually.”
In other words, it’s “View” or “Window” on other frameworks.

For example, on Win32/MFC platform, you design a “Window” resource and it has a “View” internally. On Cocoa ( for iOS ) you design UIView. In other words, you put some buttons and text lables on an instance of a UIView. On Cocoa for Mac, you first put a Window and it has NSView in it just like that of Win32/MFC.
However, if you open “res > layout” folder of an Android project, there can be “Activity” xml files which describes those visual stuffs to be presented.
So, “Activity” is not about “action” between views or windows, or action/event handlers.
Well, Google people can defend this like.. “Well, things are happening on a pane presented as view. So, we see a View as a playground on which many actions are happening. So, Activity makes sense.” Well… even though I admit it, it still feels more relevant if “Action” means the “What’s happening on those panes”, not the “pane” itself.
If a naming is this bad, even though you memorized it, you have to think about it whenever you use it. If you are a programmer only for Android, then there can be not so many problems. But if you happened to be a multiplatform-savvy programmer or if you are to use different technology on a platform like Ruby/Ruby-on-Rails, JavaScript, PHP, etc, each of them would not use same kind of “hard to understand and memorize” concept and terminologies.

Also, “Intention” is also good example. What you can think of when you heard of “Intention”.
“Hmmm… It’s for presenting what you are going to do (probably) next time.”
Right?
Well… it turned out that it’s for tossing data between event handlers and “Activity” or can be anything for passing parameters.
Well… then why do they “invent” such a new class? Wouldn’t it be better to utilize some terminology to mean “data”?
Or you can say, “Wouldn’t it be better to pass them as parameters?”
Well.. yes. But at least, if there are lots of things to toss across entities in a program, sometimes it’s better to embrace in a container and just pass a few container instant. But anyway…
In Cocoa term, “Intention” looks to be implemented using “dictionary” or in general CS term, “hash” table.
In MFC term, it will be CMap. The common naming strategy for them are the naming is based on “data type”. Because it can be used for any purpose, it’s better to have generic name. Now let’s think about “Intention”. Hmm.. is it as generic as “hash table”, “NSDictionary”, “CMap”, “CArray” etc?
No way. Also, there is already well established terminology for it, “parameter”. Then why they invent a new one “Intention”?
If I were a Google engineer, I would name it, for example, “Param”, or can be a little more creative with same approach.

Overall, I’m sorry to say this but S/W architecture portrayed from the SDK doesn’t look good either. It feels like it’s overly complicated.
It feels like my first day of seeing Mozilla CORBA-like object brokering code or MS COM. It’s like that something can be done more simply is done in hard way.

Well… making an egg stand is difficult if you think of it from the scratch for yourself. Once you know the answer, it turned out to be very simple.
However, for architecting thins like Android OS, there were a lot of existing solutions and models they can look up.
It looks like that.. it’s done by small group of people haphazardly. ( Umm.. I know the history of development of Android. )
If they keep make this architecture evolve, who knows? Probably they can run into a wall someday, which is very hard to break.

Android와 iOS에 대한 단상

Android용 Java 프레임워크는, Java SE의 그것과 좀 다른 점이 있다. 이를테면 Intent 같은 것인데, 왜 굳이 이런 디자인/아키텍쳐를 고안했는지 이해가 안간다. 뭔가 단순한 생각을 복잡하게 만든 느낌.

Android framework를 보면, 마치 Win32/MFC를 보는 느낌이다. 스타일이 비슷해서가 아니라 뭔가 흐름이.. 즉 그다지 사려깊게 디자인한 게 아니란 측면이.

그냥 돈벌기 위해서, (사실 안드로이드로는 그다지 돈이 안벌린다는 통계가 많은데) 혹은 더 많은 사용자가 생길 것을 가정하고 앱을 만드는 S/W Engineer가 있다면 이해한다. 하지만 좋은 프레임워크에 대한 고민도 개발자라면 있어야 한다.

사용자들은 어차피 내부를 모르니 동작만 하면 된다란 개발자들.. 그들 때문에 후진 아키텍쳐가 대세가 되기도 한다. 뭐 그것도 나쁘진 않다. PC가 대중화된 것을 보면. 하지만 싸서 좋다는 것과 좋은 구조를 가졌기에 좋다는 것은 다르다. 자동차나 의류 그런데선 그 둘을 사람들이 그리 구분하면서, S/W를 만드는데 필요한 도구나 언어 그리고 프레임워크/라이브러리에 대해선 그다지 “좋은 구조”를 경시하는 느낌이다.
눈에 보이지 않고 만져지지 않는 소프트웨어를 만드는 사람들이 천시 받고, 대접 받는다고 불평하기 전에, 개발자들 자신들이 자신들이 쓰는 도구에 대해 가지고 있는 생각부터 바로 잡아야하지 않을까?
안드로이드가 성공하는거.. 나쁘지 않다. 그런게 없으면 애플 넘들 가격 팍팍 올릴테니까. 하지만 그렇다고 해서 좋은 잘 만든 구조를 폄하하는 것은 다른 문제다. 어떤 시스템에 대한 이해와 존중, 그것이 S/W engineer라면.. 아니 전문가라면 필요한거 아닐까?

Follow

Get every new post delivered to your Inbox.

Join 41 other followers

%d bloggers like this: