Skip to content

XA1003 - Use a logical grouped order instead of an alphabetical order. #1

@cmaneu

Description

@cmaneu

The alphabetical order is quick and simple. However, it can leads to harder reading when the number of attributes is important. For example, FontSize and TextAlignment have a close relationship, but can be few attributes (lines) away.

Here are the different groups, and their ordering, proposed.

  • x:Key and x:Name
  • Attached properties
  • Positionning (HorizontalAlignment, VerticalAlignment, margins, z-order, stretch Canvas., Grid.)
  • Box model (width, height)
  • Typography (Font*, Foreground if text item, Text, Content)
  • Visual (background, fill, foreground , borderbrush, borderthickness, Stroke, StrokeThickness opacity, visibility, style)
  • Misc
  • Event handlers

Pros:

  • Code is ordered in a meaningful way,
  • Related attributes are grouped.

Cons:

  • Difficult to maintain without tolling support

Questions:

  • How to handle custom controls attributes ? If you are using a vendor control suite (like Telerik or Infragistics), you may have a ton of "misc" attributes.

Your feedback is welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions