|
Replies:
24
-
Last Post:
Oct 9, 2009 2:38 PM
by: cvaughn42
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
#region like what is in C#
Posted:
Sep 2, 2005 5:12 AM
|
|
|
#region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.
example:
// preprocessor_region.cs #region MyClass definition public class MyClass { public static void Main() { } } #endregion
Copied from: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcerrregion.asp
=========================================================
This should be a standardized notation that is IDEALLY backward compatiable.
NetBeans/Creator supports this syntax:
// <editor-fold defaultstate="collapsed" desc="Your Fold Comment"> ... // </editor-fold>
See: http://blogs.sun.com/roller/page/tor?entry=copyright_folding
While that works, I would personally something simpler.
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 2, 2005 12:27 PM
in response to: awf999
|
|
|
This is sort of things you could use annotations for. These can be already added to class, methods and fields and we obly missing annotations for a method body. However that would be resolved if we'll get support for a named code blocks in the language. E.g.
@Folding(comment="no need to see this ugly crap", type="AlwaysHide") { ... some text for folding }
Actually I was needed it for different reason, but it serve this purpose quite ok and also enforce block ballancing.
See my post for more details http://forums.java.net/jive/thread.jspa?threadID=988&messageID=19280#19280
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 5, 2005 12:13 AM
in response to: euxx
|
|
|
If you want Java to be C# why not use C# in the first place?
I'm sick of people trying to turn Java into whatever their favourite language is, especially as many of them will at the same time complain that Sun seems to be taking their ideas for language features from other languages...
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 5, 2005 7:24 AM
in response to: jwenting
|
|
|
> I'm sick of people trying to turn Java into whatever > their favourite language is, especially as many of > them will at the same time complain that Sun seems to > be taking their ideas for language features from > other languages...
I really wonder why you are not using Java 1.0... Any language should evolve, otherwise it is just dead.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 5, 2005 8:15 AM
in response to: euxx
|
|
|
> > I really wonder why you are not using Java 1.0... Any > language should evolve, otherwise it is just dead.
Are you suggesting that we implement every idea that comes through this forum? What would the language do if we did that. I don't think the idea is to hault langauge evoluation. However we do need to be selective about what is accepted and what isn't. There is a fine line between language features that are disruptive and those that are helpful. Sometimes innocent language features can destabilize the usability of the language. I think that is only one criteria in which changes to the language needs to be evaluated before embarking on the change because once released into the wild, there is no chance in pulling it back.
This is not a change to the language. It is about a particular annotation that I think is increadibly ugly and unnecessary since my ide understands how to fold code for me. But I would also make this suggestion. If you NEED to fold code then I'd be willing to be that you are not following good OO practices. In code that follows good design and style practices, I rarely in fact never feel the need to fold code.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 6, 2005 12:24 AM
in response to: kcpeppe
|
|
|
well said, almost exactly my idea.
The flood of useless and worse than useless demands and requests here is sickening. I've nothing against a well thought out growth of the language, but the incessant feature creep needs to stop especially in cases where the only reason to add something is either marketing (as in the SOAP functionality that's going into Mustang or annotations into Tiger) or "because XXXXX has it" which is the usual reason given by people in these here forums.
And that goes for multiple inheritance and operator overloading as well. Those were left out as funcamental language paradigms. Adding them would effectively change the entire idea behind Java, at which point it would be Java no longer but C++--##
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 7, 2005 12:41 AM
in response to: jwenting
|
|
|
> The flood of useless and worse than useless demands > and requests here is sickening.
dude... chill out!!! 
I think that we should look at features in other languages and discuss them in terms of what Java is and isn't. In this case, what Java isn't is a way to code instructions to my IDE, its a way to code instructions to my CPU! I have trouble enough getting that part to work without complicating it to configure my IDE with it? How about a UML tool? Should we have annotations in there to configure my UML tools? If so, then which one, which annotations are useful, which ones are not? Do you even know!!!
It just seems to me that this suggestion is out of scope regarding the purpose of annotations and the purpose of Java. No need to get huffy 8^)
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 7, 2005 4:53 AM
in response to: kcpeppe
|
|
|
> How about a UML tool? > Should we have annotations in there to configure my > UML tools? If so, then which one, which annotations > are useful, which ones are not? Do you even know!!!
By the way, code-level annotations would allow to hint UML tools that is doung roundtripping for non-class diagrams (e.g. sequence and activity). For instance, stick labels and other UML info to the code. Actually I love how it is been done for class diagrams in Together, but code-level annotations would allow to move things even further.
Note, that I'm not talking about 1st post in this thread, but rather reffer to the second post by me.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 7, 2005 5:06 AM
in response to: euxx
|
|
|
ok, but what about the other UML tools? maybe they have their own way of doing this and maybe their annotations are different?
One other point, tools are there to work for me. I dont' work for them period! I have enough work to do. These extra things get in my way and I'm not interested in a tool that cannot do round-tripping properly.
|
|
|
|
|
|
|
|
annotating code
Posted:
Sep 7, 2005 6:33 AM
in response to: kcpeppe
|
|
|
> ok, but what about the other UML tools? maybe they > have their own way of doing this and maybe their > annotations are different?
That is the problem and it should be adressed.
> One other point, tools are there to work for me. I > dont' work for them period! I have enough work to do. > These extra things get in my way and I'm not > interested in a tool that cannot do round-tripping > properly.
Well, we have different view here. To me source code is a diagram, and that is why Together suited my needs very well. Basically it doesn't really have roundripping, but rather using source code as a store for most of the diagram details.
|
|
|
|
|
|
|
|
Re: annotating code
Posted:
Sep 7, 2005 6:49 AM
in response to: euxx
|
|
|
> > ok, but what about the other UML tools? maybe they > > have their own way of doing this and maybe their > > annotations are different? > > That is the problem and it should be adressed.
Actually, I don't see it as a problem of the tool vendors, I see it as a strength that comes from diveristy. In that way I wouldn't want a unified set of instructions as it would be a limiting factor. > > > One other point, tools are there to work for me. I > > dont' work for them period! I have enough work to > do. > > These extra things get in my way and I'm not > > interested in a tool that cannot do round-tripping > > properly. > > Well, we have different view here. To me source code > is a diagram,
humm, source code can be used to generate a visual perspective of the relationships that are contained with-in it's constituant parts but, it in its self is not a diagram.
> and that is why Together suited my > needs very well. Basically it doesn't really have > roundripping, but rather using source code as a store > for most of the diagram details.
I like the idea of Together. Unfortunately, the implementation has not proven to be as useful as one would have hoped it to be. Desktops do not seem to be ready for TJ just yet
|
|
|
|
|
|
|
|
Re: annotating code
Posted:
Sep 7, 2005 12:32 PM
in response to: kcpeppe
|
|
|
> > > ok, but what about the other UML tools? maybe > they > > > have their own way of doing this and maybe their > > > annotations are different? > > > > That is the problem and it should be adressed. > > Actually, I don't see it as a problem of the tool > vendors, I see it as a strength that comes from > diveristy. In that way I wouldn't want a unified set > of instructions as it would be a limiting factor.
The problem is not with the tool but rather with exchanging diagrams between different UML tools. Currently you'll have to do this from scratch for every different tool. XMI doesn't really help because it has no real connection to the source.
> > Well, we have different view here. To me source > code > > is a diagram, > > humm, source code can be used to generate a visual > perspective of the relationships that are contained > with-in it's constituant parts but, it in its self is > not a diagram.
It depends. When you changed your code, wouldn't you like all diagrams to reflect the change? And vice versa...
> > and that is why Together suited my > > needs very well. Basically it doesn't really have > > roundripping, but rather using source code as a > store > > for most of the diagram details. > > I like the idea of Together. Unfortunately, the > implementation has not proven to be as useful as one > would have hoped it to be. Desktops do not seem to be > ready for TJ just yet 
I've been a successfull Together user for over 7 years. Too bad they choose to make really neat tool so bloated with all these extensions.
|
|
|
|
|
|
|
|
Re: annotating code
Posted:
Sep 12, 2005 11:18 PM
in response to: euxx
|
|
|
The programmer should never have to facillitate the tool in the way he writes his code. That's why I loathe the old versions of Netbeans and VisualAIDS Java, which did just that.
The tool should ideally anticipate what the programmer is going to do and help him do it, and at the very least never get in his way.
If the tool forces the programmer to use specific constructs or the tool won't work the tool is limiting the programmer and therefore limiting what he can achieve using that tool. That makes the tool worse than useless.
|
|
|
|
|
|
|
|
Re: annotating code
Posted:
Sep 13, 2005 4:31 AM
in response to: jwenting
|
|
|
> The programmer should never have to facillitate the > tool in the way he writes his code. > That's why I loathe the old versions of Netbeans and > VisualAIDS Java, which did just that.
So what? It will be up to any tool to save some of its own markers in a convenient place. Convenient to the tool and to the end user. Together have been using the same idea as XDoclet and I don't see why user would care if code is generated with these markers, because he don't really have to care how to save them or not to forget to send or commit tool-specific files. More over, markers can be deleted at any time and it will only affect rendering of the UML diagram.
|
|
|
|
|
|
|
|
Re: annotating code
Posted:
Sep 14, 2005 1:15 AM
in response to: euxx
|
|
|
We're talking about requiring the user to actively insert syntax the only use of which is to make their editor work correctly, and tools which prevent the user from changing generated code or worse undo manual code changes.
I've no qualms with an editor inserting some markers as long as it doesn't expect me to keep them in place and will still work correctly if those markers aren't there or aren't where it expects them to be.
For example Eclipse will insert markers to indicate to itself which Strings have been externalised or are to be ignored when externalising Strings. You're free to remove those markers and Eclipse won't mind (it just won't know to ignore those Strings next time you tell it to externalise Strings so will again suggest them). OTOH VAJ and previous versions of Netbeans (and maybe the current versions too) would generate reams of code and happily ignore any changes you made to that code, in fact reverting those changes to its own template without any warning at all or simply disallowing code to be changed outside marked regions it would insert. That's a tool hampering the user, restricting the user for the sake of the tool maker having an easier time. That's counterproductive.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 6, 2005 4:36 AM
in response to: kcpeppe
|
|
|
In my opinion, most of the ideas coming trough forum are reflecting the weak language features. Nobody is saying that every idea has to be implemented immediately, but it worth to discuss it giving more adequate arguments then "it is suxx and shoun't ever be mentioned here".
If you return to the original suggestion, which was about adding some semantical comments to hind code folding to hint IDE. Well, I have no clue how your IDE would guess to fold some code block inside large method, but I do know that annotations would work much better over there then anything you may do with comments.
Note again, that it has nothing todo with best OO practices, neither I'm suggesting not to follow them.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 6, 2005 11:35 PM
in response to: euxx
|
|
|
No, most of the ideas voiced here are just attempts to add someone's favourite feature from another language which often has no use at all in a Java context. Those ideas reflect peoples' lack of understanding of Java more than any area where Java is weak as the vast majority are things that are already quite possible in Java using a slightly different syntax (or at most requiring a line or two of code instead of a single command).
This case is a perfect example. An attempt to bring over someone's favourite feature of C# which in C# is only used in conjunction with a specific editor to provide functionality to that editor which many Java editors provide without the need for any changes to the code and the need for which more often than not indicates bad coding practices on the part of the programmer.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 7, 2005 12:22 AM
in response to: euxx
|
|
|
Why should things like that be in the Java language? Next time someone may come up with a hint for cvs to ignore some things.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 5, 2005 1:27 AM
in response to: euxx
|
|
|
Gee, why would I want to annotate my code to manually do something that I IDE does for me automatically? Seems like adding clutter to get rid of.... clutter?
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Sep 5, 2005 7:26 AM
in response to: kcpeppe
|
|
|
> Gee, why would I want to annotate my code to manually > do something that I IDE does for me automatically?
Many annotations are just hints. It is not always obvious how to treat each specific case.
|
|
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Nov 19, 2007 1:56 PM
in response to: awf999
|
|
|
I just gotta ask, are all java programmers a-holes like the few ppl in this thread? I'm a .net programmer and this seemed like a very legitimate question but geeeez did this guy get flamed or what?? I've never been on a .NET forum like this, and this was the very first java programming thread I've ever read. Now I have a real sour taste in my mouth about Java and the people who use it. If you don't want your language to evolve at all then fine, stay in the 90s and don't expect any new adopters. It seems to me that Microsoft took a long hard look at Java and all the complaints and made their own language that catered to developers instead of blasting them for asking a simple question.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Nov 20, 2007 5:40 AM
in response to: panic1
|
|
|
As flame-prone as this message was, I'll try to reply as politely as possible. I may fail, but I will try.
You've already answered your own question. No, not all Java programmers are unpleasant, and you know this. I regret your first encounter was in a small crusade, and I don't entirely approve of some answers either, but I can understand them.
First of all, the question is most certainly not a legitimate one. Asked was language support for specific IDE behaviour. The fact that the OP could not separate a development environment from a programming language speaks very poorly for the action suggested.
Secondly, Java as a language, and some of its community, has a sour history with Microsoft. You may recall J++ some time ago, which led to a number of lawsuits. Microsoft made changes to Java which made it incompatible to the base language, and then flaunted it as J++, it's own language. From this branch eventually the child called C# grew. To now have C# programmers coming over and offering how to evolve Java so that it better resembles C# leaves a bitter taste with me as it does with many others, I'm sure. And this happens very, very often.
Always remember that Microsoft works for its own store, namely the Windows family. Each of their languages typically has only one IDE, is proprietary, and thus it is easy to cope with language changes. Compare with Java, which is a cross-platform, world-wide language for which every tiny change requires each and every toolkit to adapt. So language changes are not taken lightly.
Can you really blame people for wishing proposers of language changes to at least have some experience with Java? To know the difference between a language specification, a compiler, and an IDE? To simply know what they are talking about? Admittedly, some could be friendlier about it, but I hope you can see things from another perspective as well now.
If you wish a similar experience on .NET fora --or any other, for that matter-- try arguing that using a same-line bracket style is better than a new-line bracket style, i.e.:
.public static int Main() {
// Code
}
...rather than...
.public static int Main()
{
// Code
}
...and get back to us on how that went.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Nov 22, 2007 3:09 AM
in response to: tarbo
|
|
|
And don't forget the following: 1) many of us moved to Java because of bad experience with languages, languages that people are now trying to turn Java into by adding the worst "features" of those languages to Java. 2) Java was designed to be easy to use and learn, yet most of the "proposed" "features" completely defeat that and make the language harder to use and learn for the sake of making it look more like some other language. 3) the track record Sun has when it comes to adding new "features" isn't exactly stellar. It basically does come down to implementing whatever someone proposes, the wilder and more outlandish the better, and then implementing it poorly.
So we're often hostile towards "proposed" "features" for very good reasons.
|
|
|
|
|
|
|
|
Re: #region like what is in C#
Posted:
Oct 9, 2009 2:38 PM
in response to: tarbo
|
|
|
I've done both JEE and .NET development. Initially, C# was a really well thought out language, and I've seen many features move from it to Java. The #region statement is not an IDE command, it's in the C# language specification and it's also in most of the .NET languages with subtle variations. Between you and me, it's damn useful. There are a lot of things in C# I wouldn't want brought to the Java universe, but this helpful little feature isn't one of them. Remember, most of the cost of IT comes from maintaining code, and anything that makes it easier saves money and is worthwhile.
|
|
|
|
|