« first day (92 days earlier)      last day (4847 days later) » 

11:02 PM
why is it that every time I write UI code, it feels like a hack? :(
 
@DeadMG because a hierarchy of classes, and a hierarchy of objects, is imposed and can't be be designed away. but also because the proper techniques are not well known. e.g. guys at TrollTech (now Nokia, the Qt guys) once wrote white-paper saying strong static type checking impossible
 
I haven't written any hierarchy code at all
just building a simple button class, no inheritance or anything
still feels hacky
 
@DeadMG typewise, button is a child-widget is a widget. object-wise button reside in say group widget resides in blah which is in ditto, and up. my view, you're relating to that complexity even if you restrict yourself to just the button: it exists in context
 
you know
 
11:08 PM
it feels like a hack because I don't genuinely know what the end-result should look like
 
I wouldn't be able to recognize a well-designed button class
how could I recognize my own code as well-designed if I couldn't recognize well-designed code?
 
wait..
ok, it's just my machine acting up
here's a pushbutton class that's not badly designed. but it's not best possible design either so it's been on ice since last year.
// Copyright (c) Alf P. Steinbach, 2009.
#ifndef PROGROCK_WIN32GUI_PUSHBUTTON_H
#define PROGROCK_WIN32GUI_PUSHBUTTON_H
// #include <progrock/win32gui/window/childwindow/stdcontrol/button/PushButton.h>

#include <progrock/cppx/_better_development_experience.h>

#include "../AbstractButton.h"

namespace progrock{ namespace win32gui{

    class PushButton
        : public AbstractButton
    {
        typedef AbstractButton      Base;
        typedef PushButton          Outer;


    //---------------------------- Event handling:
i surmise that the things you see there are generally not what you expected :-)
 
nope
like I don't see any code to control the text or background of the button
except in the constructor
 
11:20 PM
what I have at the moment is more like
oh that didn't work out like I expected
 
just indent all lines 4 spaces before pasting
 
it is already indented but VS uses tabs not spces
 
Only short pastes are welcome. Please, read the n00b advices there ->
:P
 
sod it, gonna use pastebin
yeah
 
Oh, ignore, I'm blind.
 
11:27 PM
lol
 
i don't understand how you place that button anywhere, is that via renderer?
 
yeah
that's in the D3D9Sprite interface
considering actually composing of the Sprite
then I can create from texture
I wish that I needed less annoying accessors
but the Direct2D versions of these interfaces can be more complex
you know, I should also validate my parameters
like those accessors will accept -1 in screen co-ordinates
 
@DeadMG you can move the transformations to a separate class. I generally had a Transformation class, which contained a vector3<T> and a quaternion<T>.
 
D3D already provides a mathematical support library
 
oh. this composition idea it's a different way of thinking than i'm used to. so it's educational. :-)
 
11:34 PM
there's no need for me to roll one
 
@Alf maybe one can pick a small subset of C and write a LLVM backend that translates it into C++ metaprograms?
 
@DeadMG ah okay. I never used DirectX so I can't say much.
 
well all the D3D9* classes are mine
Microsoft like to name theirs things like
IDirect3DDevice9
but the D3DX stuff is provided
like D3DXVECTOR3
 
@JohannesSchaublitb why C and why LLVM? ok, C because of familiar syntax. LLVM?
 
@DeadMG Microsoft and its always inconsistent type naming.
 
11:37 PM
lol
 
@AlfPSteinbach because GCC is GPLv3? haha
 
one is a COM interface, the other a helper class
would be nice if they didn't have to have
D3DXMATRIX
and
D3DXMatrixIdentity
I keep wanting to call it a D3DXMatrix or D3DXMATRIXIDENTITY
 
@DeadMG oh please, do yourself a big favour and typedef (or #define) it!
 
neh
too late now, I'd break a bunch of code :P
by the way, I've been thinking
 
@DeadMG really? I'm used to sed -i 's/bla/ble/g' *
Oh wait, you're using Windows. LMAO.
 
11:40 PM
instead of having accessors and private member variables
I should have "external representation" and "internal representation"
like
my Font object has a value for how high the font is
I was thinking that maybe, instead of pretending that it doesn't, I should just make it public
because I already have another function for changing the internal rep.
 
@DeadMG if you don't plan to sanitise it, go public.
 
well I can't have a -1 sized font, can I
 
@DeadMG use an unsigned type (uint8_t) maybe?
 
that's not really suitable for the general case
actually
I need to add actual validation
 
well, you can assert() it at some point I guess.
 
11:43 PM
should I throw for validation failed?
I'm not sure if that's exception abuse
but I return this for mem func chaining in the normal case
 
@DeadMG for me it's a clear abuse, but who am I to tell you.. I dislike exceptions.
 
well
 
@AlfPSteinbach i'm just a LLVM fanboi
 
the validations on the class are pre-known
like you can't have a -1 font height
so violating them is an exceptional circumstance
 
@DeadMG exceptional but fully recoverable.
 
11:45 PM
exceptions are intended to be catchable
catch exists for areason
 
@DeadMG which IMO is to catch non-deterministic errors.
 
programmer error is non-deterministic
and trying to set -1 as a font size is indeed a programmer error
if you're trying to set -1 as a font size, you have a bug, and there's no two ways about it
 
@DeadMG why would you raise an exception if you can just use assertions?
 
because the programmer might decide that it's a known bug setting -1 as a font size, the final build is tomorrow, and he knows the intended font size so he's just gonna swallow the exception and set a placeholder size instead
you can't, however, decide to swallow assertion failures
 
sbi
@DeadMG Which is a Good Thing(TM).
 
11:50 PM
no it isn't
programmer choice is the best thing in every circumstance
no exceptions, pun intended
 
sbi
@DeadMG I was in a multi-MLoC project for years. We had a policy against theses hacks. Still, one in ten bugs someone hunted down ended in such hacks. Thousands of "Just here, just this one time" hacks. You go nuts over this.
 
whether or not you should is another question, really
it's not my place to judge
 
@DeadMG that's exactly your role to judge. If you can avoid it, you should.
 
sbi
@DeadMG But if you should not catch exceptions that indicate programmer errors, why throw them?
 
cause it might be right for somebody else to throw them
I mean, catch them
I can't put myself into every situation, the shoes of every programmer, and say, it's always wrong, no exceptions
 
sbi
11:55 PM
@DeadMG But it is not. never. If you have a programmer error, you want to fix it.
 
if you have time and the results are bad enough
else, why don't we #define NULL nullptr in C++0x?
because fixing all the places where people used NULL that they shouldn't in legacy codebases is too expensive
 
sbi
@DeadMG I dunno. I suppose because there's millions of lines of code out there abusing NULL that are bug-free?
 
using NULL where you shouldn't is a programmer error
but we can't just go throwing exceptions if you misuse NULL, because it would simply cost too much
 
sbi
@DeadMG But it is not necessarily one that makes problem for the user. If I say char ch = NULL; then I misused NULL, but the code might be perfectly fine nevertheless.
If I say dlg.SetFontSize(-1); then that will very likely create serious trouble for the user.
 
I think the discussion deviated from its origin. You shouldn't use exceptions unless you need them. How do you know if you need them? If there's a way to avoid it, you don't need.
 
sbi
11:59 PM
@jweyrich "If there's a way to avoid it, you don't need." I don't think it's that easy either.
 

« first day (92 days earlier)      last day (4847 days later) »