473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

"Facets" or how to reduce available members...

Hi all,

this is about an idea for a language feature. Any feedback welcome.

To start with:

This is about a language feature, which would allow
to filter the set of available members of a type within a defined scope,
it is also about defining "views" for types. It's about
controlling what features / feature sets of external libraries / components
are used actively by the application programmers.

Delphi .NET class helpers (CHs) allow extending a given type
without changing the types identity. It was mentioned several
times already that Chs are not meant to be used for everyday
coding work, and where added just to allow to "connect" the VCL
with the .NET framework efficiently.

Having worked with OO languages for a while,
and having used alot of third party components I think that
quite the oposite is what application programmers would
benefit from.

Take a look at typical a component on your palette. It provides
myriads of members which deal with the different situations and
systems it has to communicate with. For a visual control f.e. there
are members to deal with the static visual appearance (like position,
site, anchors, colors etc), there are members controlling the
displayed data (like caption, colors, formats etc), and there are members
controlling a data binding (like datasource linkage). There are too members
which are only there because they are needed by the system to stream
the component, members inherited from some base objects etc.etc.
The visual editors for the components allow to setup a filter or grouping
of members when editing components visually. When working with
type "in code" you work always with the whole unfiltered set of members.

Now, when using a component within your source usually
you are not using ALL of the members at once. Mostly only a subset
of the available members is accessed in one module/class etc.
When writing a layout engine, you probably concentrate on the
layout members and not on the data binding features of a component.
When working with the data the component delivers you are not
interested in the layout properties of the component. etc. etc.
(Well ok, this is probably a little bit optimistic ... real code, real projects
tend to end up with ALL members being used in ALL places
.... real world is a bad place :-) )

When looking over the shoulder of my fellow programmers I often
see them searching for the right member of a type to use. Most of
the time they have to scan ALL of the members of type, and in most
cases the majority of the presented members (presented by CodeInsight, IntelliSense etc)
are of no use at all for the case at hand.

How about this:

Define a "Facet", which would be something similar to a Interface
definition, meaning it contains only the Signatures of members of
a type the Facet is defined for.

f.e:

public facet Position : Component {
public PositonX : Integer;
public PositonY : Integer;
public void Reposition();
}

This would be the facet "Position" defined for the type "Component".
PositionX & Y and Reposition() are members of Component,
and here they are defined to be part of the facet Position.

Now, when working with Component types this facet - when known/visible -
would filter the available members of the Component:

void foo{
Component comp = new Component(...)
comp.PositionX := 10; // (1)
comp.Name = 'newName'; // syntax error: members 'Name' not visible here
}

When calling for IntelliSence/CodeInsight at the marked line (1),
only PositionX, PostionY and Reposition() would appear in the
selection of members of comp.
Access to members not in the facet would be a syntax error.

An alternative idea could be to allow facet-names to be used
when instantiating a type like this:

void foo{
Component.Position comp = new Component(...) // I want to use the "Positon" members only
comp.PositionX := 10; // !!!
}

This would make the usage of the facet more explicit, but also
less strict as now the decision if the facet is used can
be taken every time the Component type is used.

In the first case the implicit facet has only to be "activated"
(by adding a reference to an assembly which defines it)
and then it defines the available symbols for a type within the whole module.

What do you think?

Cheerio
Radek

Nov 15 '05 #1
5 1623
"radek jedrasiak" <ra******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi all,

this is about an idea for a language feature. Any feedback welcome.
...
void foo{
Component.Position comp = new Component(...) // I want to use the "Positon" members only comp.PositionX := 10; // !!!
}

There are already several ways to accomplish the same goal without adding a
new language feature. For example, the component discussed above could
define a Position property which exposes an instance of a Positioner class
that, in turn, defines properties X and Y and method Move. IMO, the real
problem here isn't the lack of a language feature such as you described but,
rather, a failure to consider the problem of very long member lists when
designing components. The addition of a facet feature would probably
encourage even more bad design, causing more problems than it would fix.
Nov 15 '05 #2

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message news:ux**************@TK2MSFTNGP09.phx.gbl...
"radek jedrasiak" <ra******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi all,

this is about an idea for a language feature. Any feedback welcome.
...
void foo{
Component.Position comp = new Component(...) // I want to use the "Positon" members only
comp.PositionX := 10; // !!!
}

There are already several ways to accomplish the same goal without adding a
new language feature.


There's no way to change the structure of a given third party component.
I think a benefit of the proposed feature would be the possibility
to bring in some order from the outside and without the need to change
third party code f.e.

I think it would help to USE available components better.
For example, the component discussed above could
define a Position property which exposes an instance of a Positioner class
that, in turn, defines properties X and Y and method Move. IMO, the real
problem here isn't the lack of a language feature such as you described but,
rather, a failure to consider the problem of very long member lists when
designing components.
The addition of a facet feature would probably
encourage even more bad design, causing more problems than it would fix.

Very true. In the theoretical world of software
design, components and classes use classes to separate the
different concerns.
In the everyday world programmers are working today,
and probably will work for some years to come,
they are dealing with long members lists. Sure we can
wait unitl all bed component "designers" resign, or learn
better.

If the addition of the feature "encourages even more bad design",
I wonder how we could encourage good design regarding this.
You can't! People are lazy. They don't want to navigate a whole
object path until they can change a certain property of an object/component.
That's the practical reason for long member lists, in component at least.

Providing the feature does not prevent good design at all.
It gives the *application* designers one addtional tool to control
the applicaiton infrastructure in the first place. Addtionaly
it helps application developers to find the things they are looking
for more easily, and preventing them from using members they
are not supposed to use in a certain module.

cheerio
Radek
Nov 15 '05 #3

"radek jedrasiak" <ra******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
There's no way to change the structure of a given third party component.
Implementing a facet in this scenario would presumably involved creating a
wrapper for the component. If one needs to create a wrapper anyway, there
are other ways to reach the same member-grouping goal.

If the addition of the feature "encourages even more bad design",
I wonder how we could encourage good design regarding this.
You can't! People are lazy.
Yep. And they won't use facets either, so you'll still need to create your
own. To encourage good design, complain to the vendor about their bad
design. If they don't respond, complain in public/semi-public via their
support forums or whatever other similar medium might be available. Submit
a nasty review to a magazine. Threaten to take your business elsewhere.
Actually take your business elsewhere. You do have options.

Providing the feature does not prevent good design at all.
I wasn't suggesting that it would. However, IMO, it provides a shortcut via
which a poor design can be hidden too easily.

It gives the *application* designers one addtional tool to control
the applicaiton infrastructure in the first place. Addtionaly
it helps application developers to find the things they are looking
for more easily, and preventing them from using members they
are not supposed to use in a certain module.


You might want to take a look at some of the project control functionality
available via VStudio.NET Enterprise Architect edition. See
http://msdn.microsoft.com/library/en...PolicyFile.asp
for some examples of the kinds of control it allows.
Nov 15 '05 #4

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message news:%2***************@tk2msftngp13.phx.gbl...

"radek jedrasiak" <ra******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
There's no way to change the structure of a given third party component.
Implementing a facet in this scenario would presumably involved creating a
wrapper for the component. If one needs to create a wrapper anyway, there
are other ways to reach the same member-grouping goal.

If the addition of the feature "encourages even more bad design",
I wonder how we could encourage good design regarding this.
You can't! People are lazy.


Yep. And they won't use facets either, so you'll still need to create your
own.


YES!!!! That's what I'm after. With facets I can use this "badly" desinged
component and add some order to it.
To encourage good design, complain to the vendor about their bad
design. If they don't respond, complain in public/semi-public via their
support forums or whatever other similar medium might be available. Submit
a nasty review to a magazine. Threaten to take your business elsewhere.
Actually take your business elsewhere. You do have options.


Yes these some options. Biz-options only, actually. Developers
also need technical options. Facets are about exactly that.
Providing the feature does not prevent good design at all.


I wasn't suggesting that it would. However, IMO, it provides a shortcut via
which a poor design can be hidden too easily.


I partly agree. You are right this is also a workaround for the issues
you already stated before.
Addtionaly I think that facets would also provide a tool to
control what and how is used within an application system.
Can't see anything bad with that.
It gives the *application* designers one addtional tool to control
the applicaiton infrastructure in the first place. Addtionaly
it helps application developers to find the things they are looking
for more easily, and preventing them from using members they
are not supposed to use in a certain module.


You might want to take a look at some of the project control functionality
available via VStudio.NET Enterprise Architect edition. See
http://msdn.microsoft.com/library/en...PolicyFile.asp
for some examples of the kinds of control it allows.


Thanks. The "Enterprise Template Policy File" only can
be applied to the IDE and does not control at all how developers
deal with code in source.
Facets are more about that: compile time control of the way
symbols and members are accessed within a module.

Cheerio
Radek
Nov 15 '05 #5
"radek jedrasiak" <ra******@hotmail.com> wrote in message
news:Oi**************@TK2MSFTNGP11.phx.gbl...
The "Enterprise Template Policy File" only can
be applied to the IDE and does not control at all how developers
deal with code in source.
Facets are more about that: compile time control of the way
symbols and members are accessed within a module.


Have you considered using custom attributes to achieve this goal? Besides
applying usage restrictions, you might even be able to affect IntelliSense
display. Personally, I still think that creating a "well behaved" wrapper
is a better approach than either facets or an attribute approach. In
addition to allowing control over access to the component members, it also
provides encapsulation of this access in such a way as to minimize the
effort required to adjust an application to work against new versions of the
component.
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
2
by: Steven T. Hatton | last post by:
I'm still not completely sure what's going on with C++ I/O regarding the extractors and inserters. The following document seems a bit inconsistent:...
32
by: Fresh Air Rider | last post by:
Hi I understand that ASP.net 2.0 (Whidbey) is going to reduce coding by 70%. Surely this is going to de-skill or dumb down the developer's task and open up the task of web development to less...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.