Frank Hileman's WebLog

Vector Graphics with VG.net and Visual Studio Integration

New Names for Classes and Namepaces

To simplify both code and xml files, we are considering the following set of name changes for Types in VG.net. If you use VG.net, and have an opinion on these changes, please post a comment.

Note we will keep the name of the Type and the name of any property of that Type identical. For example, currently the Style class has a property named TextStyle, which returns an instance of the TextStyle class.

First, classes related to object appearances (styling).

Current Name

New Name

Notes

Style

Style

No change. A Style currently contains one of each: BrushStyle, PenStyle, TextStyle, and RenderStyle.

SubStyle

AppearanceProperties

SubStyle is currently the name of the base class for BrushStyle, PenStyle, TextStyle, and RenderStyle.

BrushStyle

Fill

This class specifies the appearance of filled interior areas in shapes, as well as the fill used within TextStyle (TextProperties) and PenStyle (Stroke). Since Fill is a base class, the name change would affect a number of derived classes: SolidBrushStyle becomes SolidFill, etc.

PenStyle

Stroke

Specifies the appearance of shape edges. Contains a BrushStyle (Fill).

TextStyle

TextProperties

Specifies the appearance of text. Contains a BrushStyle (Fill). We cannot simply change the name to Text, as there is a string Text property in each Shape.

RenderStyle

RenderProperties

Specifies rendering options: anti-aliasing, gamma-corrected or linear composting of translucent pixels, and the pixel offset mode.

Here are newly proposed names for various Shape classes.

Current Name

New Name

Notes

RectangleShape

Rectangle

This will cause a conflict with the integer rectangle System.Drawing.Rectangle. Because all coordinates in VG.net are stored as floats, we believe code using integer rectangles may rarely mix with VG.net code. If many people believe the conflict will cause problems, we can leave RectangleShape as is.

EllipseShape

Ellipse

 

ArcShape

Arc

 

PieShape

Pie

 

PolylineShape

Polyline

 

SplineShape

Spline

 

PathShape

Path

 

Finally, we are proposing changes to our namespaces and dlls:

Current Name

New Name

ProdigeSoftware.Drawing

Prodige.Drawing

ProdigeSoftware.Drawing.Styles

Prodige.Drawing.Styles

ProdigeSoftware.Drawing.dll

Prodige.Drawing.dll

Published Sunday, March 28, 2004 10:05 AM by Frank Hileman

Comments

# re: New Names for Classes and Namepaces@ Sunday, March 28, 2004 2:03 PM

Looks good to me

by Brad Jones

# re: New Names for Classes and Namepaces@ Sunday, March 28, 2004 3:05 PM

I think keeping *Shape can be a good idea... confusion with Rectangle or Win32 API (Ellipse, Polyline, etc... are win32 api) should be avoided.

Mixing Style and Properties seems strange to me... is it style (sound more like something you can apply on many object) or properties (sound more like something actually applied to one object)? The class that inherit from style are properties, or sometimes not, sometimes they're just Fill and Stroke...?

Also for GDI(+) users, Brush and Pen are something, Fill sound likes flood fill and stroke looks like a way to surround an object. Maybe it could be a good idea to keep and use "current knowledge" to soften the learning curve?

ps: no I'm not against all change... :p

# re: New Names for Classes and Namepaces@ Sunday, March 28, 2004 3:16 PM

One more note: we looked at the MyXaml export (just implemented), and compared it with real Xaml. The "Shape" suffix looks clumsy. The "Style" suffix is accurate, but becomes wordy (LinearGradientBrushStyle) and there is another class called Style, not in the same inheritance hierarchy. These were some of the motivations.

Quentin: Style means what you think. But a Style object is broken into several pieces, each of which covers one area (BrushStyle, PenStyle, etc). There are no classes inheriting from Style (the "pieces" inherit from SubStyle).

We could not use Brush or Pen directly, because of the GDI+ conflict.

# re: New Names for Classes and Namepaces@ Sunday, March 28, 2004 9:26 PM

I say leave the Shape on the end of rectangle and etc., but I think all other changes seem worthy.

# re: New Names for Classes and Namepaces@ Monday, March 29, 2004 7:43 AM

not bad
but i would change Fill to FillProperties

# re: New Names for Classes and Namepaces@ Monday, March 29, 2004 7:50 AM

My preference would be to use FillProperties rather than Fill and StrokeProperties rather than Stroke.

As for the ..Shape argument: they're in a separate namespace from System.Drawing so why not use the same class names?

# re: New Names for Classes and Namepaces@ Monday, March 29, 2004 9:07 AM

Derek: There is no conflict with System.Drawing, or anthing else, except for System.Drawing.Rectangle. Since they are in separate namespaces, even that is not a real "conflict," as you note. But if people do this:

using System.Drawing;
using Prodige.Drawing;

They will have to qualify every use of Rectangle, or do something like this:

using Rect = System.Drawing.Rectangle;

Designer generated code is not a problem, since it is always fully qualified.

# re: New Names for Classes and Namepaces@ Tuesday, March 30, 2004 12:12 AM

I think most of the name changes are good. The postfix of 'Shape' always seemed a bit verbose to me for these objects, seeing as it's easy to identify that they are shapes.
My suggestion would be to drop them into their own namespace. e.g. Prodige.Drawing.Shapes. This way a user can import the whole thing if they know there will not be a conflict with System.Drawing.Rectangle, or just import Prodige.Drawing and prefix everything with 'Shapes.' - this adds (IMHO) clarity to code (reading 'Shapes.Arc' seems cleaner than 'ArcShape' and since it's separated makes it easier to identify) and would also play nice with intellisense.

I think the assembly/namespace changes are nice - makes things look a little more standard and a bit cleaner. 'Microsoft' instead of 'MicrosoftInc' is desirable because of the same idea :)

Good job!

by Ben

# re: New Names for Classes and Namepaces@ Tuesday, March 30, 2004 8:26 AM

Hi Ben! Your idea is interesting, but adding another namespace to the mix makes every file a little more complex.

It is possible to avoid importing Prodige.Drawing. But perhaps our namespace should be called something else, like Prodige.Graphics. This way, the technique you propose could still be used, but would look like this:

using Prodige;
...
Graphics.Rectangle = new Graphics.Rectangle();

Perhaps the Drawing name was a bad choice.

But the Graphics choice is not good either! There is a Graphics class in System.Drawing. Anyone have any good ideas here? "Shapes" really doesn't cover the richness of the API.