Visual Studio not visual enough (updated, pics inside :)

This topic is 4016 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have read in some coding guidelines for C# that classes member should be alphabetized, and grouped into sections (Fields, Constructors, Properties, Events, Methods...). I may be lazy but doing that is really boring and does nothing to improve program I am developing. Sure it helps a lot for code to be more readable, but couldn't this be done by some more advanced text editor? And it would save me a lot of time. There are some visual representations of classes in VS, but when I want to edit contents of some class it always opens this text editor with hundreds of lines where it is easy to get lost (well at least I do sometimes). Wouldn't be nice if some kind of a hybrid editor opened, where classes members would automatically be grouped into sections and alphabetized. You could sort members, show/hide them by accessibility, group them (aka regions) and even edit members attributes. When you would double click on some method code would show inside that editor or in separate window, but it would only show that single method (so you don't get distracted by other code). It would be some kind hybrid visual/text editor. Contents (classes, members of classes) of a file would be presented visually and body of members the way it is now (text). What do you think? It sure would improve my productivity. EDIT: below I have posted a better explanation (with pics:) of what I meant [Edited by - zz2 on September 28, 2007 8:10:10 AM]

Share on other sites
Maybe this application could be of some help:

http://sourceforge.net/projects/classbuilder/

This is one of my favourite applications!
It is very convenient for creating new classes, methods, member variables and then exporting/saving the source files.

It is for C++ though so it might not be useful for you.

Share on other sites
I'm already in the habit of grouping my variables and functions and so forth together by category by hand. Frankly, the kind of category sections you list seem worthless to me, and no automated system could hope to group things together by the kind of sections that are useful to me.

It's very similar to the Apps vs Systems Hungarian Notation Debate -- I find codification of actual types of things (such as "event", "constructor", etc) to be useless compared to codification of actual usage of things (to take some mundane examples of a container class: "member access", "memory storage manipulation", and "list processing").

Sidenote:
- I find Systems Hungarian at best harmful, at worst a crime against coderanity.
- I find Apps Hungarian useful, but I prefer to codify such things with names instead of acronyms, or better yet, more logical grouping and seperation of such things at the type system or structural level, 99% of the time.

I also alphabetize my #includes in C++, but for almost anywhere else, I find that if something could benefit from alphabetization, it's such a horrible unwieldy mess that I can't in good conscious avoid refactoring it. Really, #include alphabetization is just a shortcut for category organization for me anyways -- I always start with the outermost categories in my paths and filenames (e.g. "things/foods/pastry.caek.hpp"), so related things end up next to each other in the #include list using this mechanism.

Edit: This is underscored by the fact that I have a couple of alphabetization exceptions: I put boost, the standard C++ library, and other "external" library #includes after my inter-project ones, with their own seperate sub-alphabetization.

In summary: You're barking up the tree squirrel went up, which is all fine and good. But the squirrel is a ninja. Protect your nuts and thrive, but to do this you must follow his movements as he moves from tree to tree, or you'll be left barking up the wrong one.

Edit: Slightly less fun summary: Yes, be visual, group your text together in useful ways -- you can do this with existing text editors. While copy and paste are the tools of evil duplication, I'm not alone in having mastered them for divine relocation. But I don't think it's going to be possible to automate this in a useful way until further advances in AI, and I don't think slapping eye candy on it is going to help much either.

[Edited by - MaulingMonkey on September 27, 2007 6:25:22 AM]

Share on other sites
@neatdev: no, that app is not really what I was thinking..

@MaulingMonkey: I have started learning C# about a year ago, so I am in no way experienced developer. As I was(am) learning I wanted to know if there is any "standard" way of organising code inside class and I found these guidelines that suggest that class members should be grouped by type. I agree with you that it is much more useful to group things by usage (logic), but sometimes it is useful to have members grouped by type and why choose one style when you can have both ;) You wrote that alphabetization is not really useful. Well then it should be an option that you can turn on and off on the fly. The main point of that editor would not be automation, but easier, faster editing of a class.

I was searching what kinds of code editors already exist (visual and non-visual). Existent visual editors seem no good. Too much clicking for something that can be written with few keystrokes. VS code editor is not visual editor but has some visual elements: method bodies can be collapsed and #region. And I was talking about an editor which would evolve from VS editor. I still believe that the editor I am imagining should be useful :) Maybe I should sketch it for better explanation. (if I will have some time :)

Share on other sites
Code style guidelines serve primarily one purpose - giving a common look and feel to entire code-base.

Some guidelines improve readability, others don't.

But ultimately, the proposed enforcement of member organization isn't commonly used, as such such style would be considered counter-productive in some environments.

Visually generated code tends to be less readable. VS is no exception.

The best and by far most productive solution to this is: If you can edit a part of code exclusively through GUI, do so. If you can't, develop it in external file.

Auto-generated classes should be considered as such. Use the UI editor for editing the GUI, not organizing the code. Those classes are already littered with too much auto-initialization and auto-generated code.

In C#, you have the option of partial class definitions. Embrace that - it'll do more to improve readability than any other tool could offer.

The time-saving benefits you're proposing are non-existent. The reason for this is, if you find yourself writing a lot of boiler-plate code, the problem lies elsewhere.

Can you write helper classes to wrap the functionality you're repeating most? Can you change the workflow of the application?

This problem is common in IDL heavy environments. There, auto-generated code *needs* to be 100% auto-generated, or you have maintainance disaster. Try to apply the same principles to your problem. UI is just for linking underlying, externally implemented and defined functionality. UI code will always be spaghetti code, at very least, after you come back to other's code, or after you've come back to project.

I partially resent the regions. They are a solution to fundamental problem. Rather than encouraging improvement in design, they hide it under the carpet.

Your problem comes from design. You're too visually oriented. The solution is in improving the design, not getting a better hammer.

Share on other sites
My general feeling is that if your class is accumulating so many methods and data members that you need to organize them, then your class probably has too many responsibilities and is really several classes glommed together into a big ball of mud.

Share on other sites
OK first should I say that I am not talking about visual class designers or auto-generated code. Its probably my fault. I wasn't clear enough.

The purpose of this thread is to ask you guys what do you think could be done to improve VS's code editor.
Like VS's code editor is improvement over notepad. (there might be someone who would say: "VS's code editor is for n00bs, true programmer writes his code in notepad, because it is design that matters", but I doubt it :) sure design matters a lot, but it is not absolute everything... hammer-head made of iron is better than hammer-head made of wood, right? (<-lol what a lousy metaphor ;)

So to give a better example I have made a sketch of (in my opinion) improved code editor. It solves "problems" with particular design guidelines I wrote about in first post:
- With use of it you could group items by their actual usage (most probably agree that this is a better way of grouping) like MaulingMonkey have said.
- You could also view and group members in a way coding guidelines (I posted in second post) recommends. This could be done with "Document's classes view" (see pic below) and to some degree inside code editor itself, without changing the code(by using filters).
- It also improves hiding (collapsing) of code. So that you see only code that you currently need and that you can find code you are searching for faster (isn't it true that if you search in VS for something in a file with 50 lines you will find it faster than in a file with 300+ lines)

example: code I used is "CustomScrollControl.cs" form this open source project

here is the code:
using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Data;using System.Windows.Forms;namespace SourceGrid2{	/// <summary>	/// A control with a custom implementation of a scrollable area	/// </summary>	[System.ComponentModel.ToolboxItem(false)]	public abstract class CustomScrollControl : System.Windows.Forms.Panel	{		#region Constructor		/// <summary>		/// Constructor		/// </summary>		public CustomScrollControl()		{			SuspendLayout();			base.AutoScroll = false;			//to remove flicker and use custom draw			SetStyle(ControlStyles.UserPaint, true);			SetStyle(ControlStyles.AllPaintingInWmPaint, true);			//SetStyle(ControlStyles.DoubleBuffer, true);			//SetStyle(ControlStyles.Opaque, true);			//SetStyle(ControlStyles.ResizeRedraw, true);			ResumeLayout(false);		}		#endregion		#region override AutoScroll		/// <summary>		/// I disabled the default AutoScroll property because I have a custom implementation		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public override bool AutoScroll		{			get{return false;}			set			{				if (value)					throw new SourceGridException("Auto Scroll not supported in this control");				base.AutoScroll = false;			}		}		#endregion		#region ScrollBars and Panels		private VScrollBar m_VScroll = null;		private HScrollBar m_HScroll = null;		private Panel m_BottomRightPanel = null;		/// <summary>		/// Represent the vertical scrollbar. Can be null.		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public VScrollBar VScrollBar		{			get{return m_VScroll;}		}		/// <summary>		/// Represent the horizontal scrollbar. Can be null.		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public HScrollBar HScrollBar		{			get{return m_HScroll;}		}		/// <summary>		/// Represent the panel at the bottom right of the control. This panel is valid only if HScrollBar and VScrollBar are valid. Otherwise is null.		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public Panel BottomRightPanel		{			get{return m_BottomRightPanel;}		}		/// <summary>		/// Invalidate the scrollable area		/// </summary>		protected abstract void InvalidateScrollableArea();		#endregion		#region ScrollArea, ScrollPosition, DisplayRectangle		private Size m_CustomScrollArea = new Size(0,0);		/// <summary>		/// Represent the logical area of the control that must be used for scrolling		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public virtual Size CustomScrollArea		{			get{return m_CustomScrollArea;}			set			{				if (m_CustomScrollArea != value)				{					m_CustomScrollArea = value;					RecalcCustomScrollBars();				}			}		}		/// <summary>		/// Represent the current scroll position relative to the CustomScrollArea		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public virtual Point CustomScrollPosition		{			get			{				int l_x = 0;				if (m_HScroll!=null)					l_x = -m_HScroll.Value;				int l_y = 0;				if (m_VScroll!=null)					l_y = -m_VScroll.Value;				return new Point(l_x,l_y);			}			set			{				if (m_HScroll!=null)					m_HScroll.Value = -value.X;				if (m_VScroll!=null)					m_VScroll.Value = -value.Y;			}		}		/// <summary>		/// Display rectangle of the control, without ScrollBars		/// </summary>		public override Rectangle DisplayRectangle		{			get			{				int l_ScrollH = 0;				if (m_HScroll!=null)					l_ScrollH = m_HScroll.Height;				int l_ScrollV = 0;				if (m_VScroll!=null)					l_ScrollV = m_VScroll.Width;				Rectangle l_Base = base.DisplayRectangle;				return new Rectangle(l_Base.X, l_Base.Y, l_Base.Width-l_ScrollV, l_Base.Height-l_ScrollH);			}		}		#endregion		#region Point and Rectangle Relative/Absolute conversion		/// <summary>		/// Convert an absolute rectangle from the total scrolling area to the current displayrectangle.		/// </summary>		/// <param name="p_AbsoluteRectangle"></param>		/// <returns></returns>		public Rectangle RectangleAbsoluteToRelative(Rectangle p_AbsoluteRectangle)		{			return new Rectangle(PointAbsoluteToRelative(p_AbsoluteRectangle.Location),p_AbsoluteRectangle.Size);		}		/// <summary>		/// Convert a relative rectangle from the current displayrectangle to an absolute rectangle for the current scrolling area.		/// </summary>		/// <param name="p_RelativeRectangle"></param>		/// <returns></returns>		public Rectangle RectangleRelativeToAbsolute(Rectangle p_RelativeRectangle)		{			return new Rectangle(PointRelativeToAbsolute(p_RelativeRectangle.Location),p_RelativeRectangle.Size);		}		/// <summary>		/// Convert a relative point from the current displayrectangle to an absolute point to the total scrolling area.		/// </summary>		/// <param name="p_RelativePoint"></param>		/// <returns></returns>		public Point PointRelativeToAbsolute(Point p_RelativePoint)		{			Point l_ScrollPos = CustomScrollPosition;			return new Point(p_RelativePoint.X-l_ScrollPos.X, p_RelativePoint.Y-l_ScrollPos.Y);		}		/// <summary>		/// Convert a absolute point from an absolute point to the current displayrectangle of the grid.		/// </summary>		/// <param name="p_AbsolutePoint"></param>		/// <returns></returns>		public Point PointAbsoluteToRelative(Point p_AbsolutePoint)		{			Point l_ScrollPos = CustomScrollPosition;			return new Point(p_AbsolutePoint.X+l_ScrollPos.X, p_AbsolutePoint.Y+l_ScrollPos.Y);		}		#endregion		#region Add/Remove ScrollBars		/// <summary>		/// Remove the horizontal scrollbar		/// </summary>		protected virtual void RemoveHScrollBar()		{			if (m_HScroll != null)			{				HScrollBar l_tmp = m_HScroll;				m_HScroll = null;				l_tmp.ValueChanged -= new EventHandler(HScroll_Change);				Controls.Remove(l_tmp);				l_tmp.Dispose();				l_tmp = null;			}			m_OldHScrollValue = 0;		}		/// <summary>		/// Remove the vertical scrollbar		/// </summary>		protected virtual void RemoveVScrollBar()		{			if (m_VScroll != null)			{				VScrollBar l_tmp = m_VScroll;				m_VScroll = null;				l_tmp.ValueChanged -= new EventHandler(VScroll_Change);				Controls.Remove(l_tmp);				l_tmp.Dispose();				l_tmp = null;			}			m_OldVScrollValue = 0;		}		/// <summary>		/// Insert the horizontal scroll bar		/// </summary>		protected virtual void InsertHScrollBar()		{			if (m_HScroll == null)			{				m_HScroll = new HScrollBar();				m_HScroll.TabStop = false;				m_HScroll.ValueChanged += new EventHandler(HScroll_Change);				Controls.Add(m_HScroll);			}		}		/// <summary>		/// Insert the vertical scroll bar		/// </summary>		protected virtual void InsertVScrollBar()		{			if (m_VScroll == null)			{				m_VScroll = new VScrollBar();				m_VScroll.TabStop = false;				m_VScroll.ValueChanged += new EventHandler(VScroll_Change);				Controls.Add(m_VScroll);			}		}		/// <summary>		/// recalculate the position of the horizontal scrollbar		/// </summary>		protected virtual void RecalcHScrollBar()		{			if (m_HScroll != null)			{				int l_WidthVScroll = 0;				if (m_VScroll != null)					l_WidthVScroll = m_VScroll.Width;				m_HScroll.Location = new Point(0,ClientRectangle.Height-m_HScroll.Height);				m_HScroll.Width = ClientRectangle.Width-l_WidthVScroll;				m_HScroll.Minimum = 0;				m_HScroll.Maximum = Math.Max(0,m_CustomScrollArea.Width); //Math.Max(0,m_CustomScrollArea.Width - ClientRectangle.Width) + m_VScroll.Width;				m_HScroll.LargeChange = Math.Max(5,ClientRectangle.Width - l_WidthVScroll);				m_HScroll.SmallChange = m_HScroll.LargeChange / 5;				if (m_HScroll.Value > MaximumHScroll)					m_HScroll.Value = MaximumHScroll;				m_HScroll.BringToFront();			}		}		/// <summary>		/// Recalculate the position of the vertical scrollbar		/// </summary>		protected virtual void RecalcVScrollBar()		{			if (m_VScroll != null)			{				int l_HeightHScroll = 0;				if (m_HScroll != null)					l_HeightHScroll = m_HScroll.Height;				m_VScroll.Location = new Point(ClientRectangle.Width-m_VScroll.Width,0);				m_VScroll.Height = ClientRectangle.Height-l_HeightHScroll;				m_VScroll.Minimum = 0;				m_VScroll.Maximum = Math.Max(0,m_CustomScrollArea.Height); //Math.Max(0,m_CustomScrollArea.Height - ClientRectangle.Height) + m_HScroll.Height;				m_VScroll.LargeChange = Math.Max(5,ClientRectangle.Height - l_HeightHScroll);				m_VScroll.SmallChange = m_VScroll.LargeChange / 5;				if (m_VScroll.Value > MaximumVScroll)					m_VScroll.Value = MaximumVScroll;				m_VScroll.BringToFront();			}		}		/// <summary>		/// Recalculate the scrollbars position and size		/// </summary>		protected virtual void RecalcCustomScrollBars()		{			//Check the size of the control			Size l_BaseDisplaySize = base.DisplayRectangle.Size; //il base non tiene conto delle scrollbar ed &#269; quello che voglio			if (l_BaseDisplaySize.Height < m_CustomScrollArea.Height)				InsertVScrollBar();			else				RemoveVScrollBar();			if (l_BaseDisplaySize.Width < m_CustomScrollArea.Width)				InsertHScrollBar();			else				RemoveHScrollBar();			//Re-Check with the size of the ClientRectangle (that if before I added a scrollbar is smaller then the Size)			Size l_DisplaySize = DisplayRectangle.Size;			if (l_DisplaySize.Height < m_CustomScrollArea.Height)				InsertVScrollBar();			if (l_DisplaySize.Width < m_CustomScrollArea.Width)				InsertHScrollBar();			//if there is only one or zero scrollbar remove the BottomRightPanel			if (m_HScroll == null || m_VScroll == null)			{				if (m_BottomRightPanel!=null)				{					Controls.Remove(m_BottomRightPanel);					m_BottomRightPanel.Dispose();					m_BottomRightPanel = null;				}			}			RecalcVScrollBar();			RecalcHScrollBar();			//se sono tutti e due abilitati aggiungo il BottomRightPanel			if (m_HScroll != null && m_VScroll != null)			{				if (m_BottomRightPanel==null)				{					m_BottomRightPanel = new Panel();					m_BottomRightPanel.TabStop = false;					m_BottomRightPanel.BackColor = Color.FromKnownColor(KnownColor.Control);					Controls.Add(m_BottomRightPanel);				}				m_BottomRightPanel.Location = new Point(m_HScroll.Right,m_VScroll.Bottom);				m_BottomRightPanel.Size = new Size(m_VScroll.Width,m_HScroll.Height);				m_BottomRightPanel.BringToFront();			}			//forzo un ridisegno			InvalidateScrollableArea();		}		#endregion		#region Maximum/Minimum Scroll Position		/// <summary>		/// Return the maximum position that can be scrolled		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public virtual int MaximumVScroll		{			get			{				if (m_VScroll == null)					return 0;				else					return m_VScroll.Maximum-m_VScroll.LargeChange;			}		}		/// <summary>		/// Return the minimum position that can be scrolled		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public virtual int MinimumVScroll		{			get			{				return 0;			}		}		/// <summary>		/// Return the minimum position that can be scrolled		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public virtual int MinimumHScroll		{			get			{				return 0;			}		}		/// <summary>		/// Return the maximum position that can be scrolled		/// </summary>		[Browsable(false),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]		public virtual int MaximumHScroll		{			get			{				if (m_HScroll == null)					return 0;				else					return m_HScroll.Maximum-m_HScroll.LargeChange;			}		}		#endregion		#region Layout Events		/// <summary>		/// OnLayout Method		/// </summary>		/// <param name="e"></param>		protected override void OnLayout(LayoutEventArgs e)		{			base.OnLayout(e);			RecalcCustomScrollBars();		}		#endregion		#region ScrollChangeEvent		private int m_OldVScrollValue = 0;		private void VScroll_Change(object sender, EventArgs e)		{			OnVScrollPositionChanged(new ScrollPositionChangedEventArgs(-m_VScroll.Value,-m_OldVScrollValue));			InvalidateScrollableArea();			m_OldVScrollValue = m_VScroll.Value;		}		private int m_OldHScrollValue = 0;		private void HScroll_Change(object sender, EventArgs e)		{			OnHScrollPositionChanged(new ScrollPositionChangedEventArgs(-m_HScroll.Value,-m_OldHScrollValue));			InvalidateScrollableArea();			m_OldHScrollValue = m_HScroll.Value;		}		/// <summary>		/// Fired when the scroll vertical posizion change		/// </summary>		public event ScrollPositionChangedEventHandler VScrollPositionChanged;		/// <summary>		/// Fired when the scroll vertical posizion change		/// </summary>		/// <param name="e"></param>		protected virtual void OnVScrollPositionChanged(ScrollPositionChangedEventArgs e)		{			if (VScrollPositionChanged!=null)				VScrollPositionChanged(this,e);		}		/// <summary>		/// Fired when the scroll horizontal posizion change		/// </summary>		public event ScrollPositionChangedEventHandler HScrollPositionChanged;		/// <summary>		/// Fired when the scroll horizontal posizion change		/// </summary>		/// <param name="e"></param>		protected virtual void OnHScrollPositionChanged(ScrollPositionChangedEventArgs e)		{			if (HScrollPositionChanged!=null)				HScrollPositionChanged(this,e);		}		#endregion		#region Scroll PageDown/Up/Right/Left/LineUp/Down/Right/Left		/// <summary>		/// Scroll the page down		/// </summary>		public virtual void CustomScrollPageDown()		{			if (m_VScroll!=null)				m_VScroll.Value = Math.Min(m_VScroll.Value + m_VScroll.LargeChange, m_VScroll.Maximum-m_VScroll.LargeChange);		}		/// <summary>		/// Scroll the page up		/// </summary>		public virtual void CustomScrollPageUp()		{			if (m_VScroll!=null)				m_VScroll.Value = Math.Max(m_VScroll.Value - m_VScroll.LargeChange, m_VScroll.Minimum);		}		/// <summary>		/// Scroll the page right		/// </summary>		public virtual void CustomScrollPageRight()		{			if (m_HScroll!=null)				m_HScroll.Value = Math.Min(m_HScroll.Value + m_HScroll.LargeChange, m_HScroll.Maximum-m_HScroll.LargeChange);		}		/// <summary>		/// Scroll the page left		/// </summary>		public virtual void CustomScrollPageLeft()		{			if (m_HScroll!=null)				m_HScroll.Value = Math.Max(m_HScroll.Value - m_HScroll.LargeChange, m_HScroll.Minimum);		}		/// <summary>		/// Scroll the page down one line		/// </summary>		public virtual void CustomScrollLineDown()		{			if (m_VScroll!=null)				m_VScroll.Value = Math.Min(m_VScroll.Value + m_VScroll.SmallChange, m_VScroll.Maximum);		}		/// <summary>		/// Scroll the page up one line		/// </summary>		public virtual void CustomScrollLineUp()		{			if (m_VScroll!=null)				m_VScroll.Value = Math.Max(m_VScroll.Value - m_VScroll.SmallChange, m_VScroll.Minimum);		}		/// <summary>		/// Scroll the page right one line		/// </summary>		public virtual void CustomScrollLineRight()		{			if (m_HScroll!=null)				m_HScroll.Value = Math.Min(m_HScroll.Value + m_HScroll.SmallChange, m_HScroll.Maximum);		}		/// <summary>		/// Scroll the page left one line		/// </summary>		public virtual void CustomScrollLineLeft()		{			if (m_HScroll!=null)				m_HScroll.Value = Math.Max(m_HScroll.Value - m_HScroll.SmallChange, m_HScroll.Minimum);		}		#endregion	}}

here is a screenshot of how that code looks like in VS's 2005 code editor:

and how it would look like in somewhat improved code editor:

there are some descriptions in boxes, for the rest use your imagination

So what are your thoughts, ideas?

EDIT: the example I posted is meant for C# code editor

Share on other sites
Eh, I dunno. I would absolutely hate that kind of interface. I hate #regions already, and code folding; I disable them.

The only rationale I ever really see for these sorts of "let's move my information around and hide/show it for me" editor tools all basically boil down to "I'm a lazy programmer," or "I'm a bad programmer and my code sucks because I don't have the discipline to organize it myself."

Furthermore, they really start to encroach upon the barrier between textual and visual programming paradigms -- and visual programming is generally accepted to be horribly inefficient as compared to the more familiar textual context, especially at the typical scope actual programmers tend to work.

The IDE already has a "list of members" drop down that can be used to locate anything alphabetically, and proper organization on the part of the programmer should be sufficient to group by type or logical usage -- it's not that hard, and its impossible to automate anyway. As for hiding and folding, I've never had a good reason to use it, ever. It's not like having other code on the screen gets in the way -- unless that code is horribly, distractably misformatted, in which case, fix it. Clean up the formatting, or if it's ugly because there are too many members or functions or whatever, that likely means the class is doing too much and you need to refactor it anyway.

Share on other sites
Check out VisualAssist. In addition to its refactoring and code completion and syntax highlighting and code browsing and other stuff, it now has features for quickly and accurately reordering code blocks. I tried programming with a copy of Visual Studio that didn't have VisualAssist installed the other day. It wasn't a fun experience.

Share on other sites
The code referenced is quite messy.

But then there's just plain lazy old copy-paste like this:
protected virtual void RemoveHScrollBar()		{			if (m_HScroll != null)			{				HScrollBar l_tmp = m_HScroll;				m_HScroll = null;				l_tmp.ValueChanged -= new EventHandler(HScroll_Change);				Controls.Remove(l_tmp);				l_tmp.Dispose();				l_tmp = null;			}			m_OldHScrollValue = 0;		}		/// <summary>		/// Remove the vertical scrollbar		/// </summary>		protected virtual void RemoveVScrollBar()		{			if (m_VScroll != null)			{				VScrollBar l_tmp = m_VScroll;				m_VScroll = null;				l_tmp.ValueChanged -= new EventHandler(VScroll_Change);				Controls.Remove(l_tmp);				l_tmp.Dispose();				l_tmp = null;			}			m_OldVScrollValue = 0;		}

This screams "Refactor Me!" in agony.

And looking at where code is used:
			Size l_BaseDisplaySize = base.DisplayRectangle.Size; //il base non tiene conto delle scrollbar ed &#269; quello che voglio	if (l_BaseDisplaySize.Height < m_CustomScrollArea.Height)		InsertVScrollBar();	else		RemoveVScrollBar();	if (l_BaseDisplaySize.Width < m_CustomScrollArea.Width)		InsertHScrollBar();	else		RemoveHScrollBar();	//Re-Check with the size of the ClientRectangle (that if before I added a scrollbar is smaller then the Size)	Size l_DisplaySize = DisplayRectangle.Size;	if (l_DisplaySize.Height < m_CustomScrollArea.Height)		InsertVScrollBar();	if (l_DisplaySize.Width < m_CustomScrollArea.Width)		InsertHScrollBar();

Yes, the code mentioned is much messier than it should be. Visual Editor for mess will not help.

Refactoring the code will. C# is *perfect* language for refactoring.

This code is typical for RAD-like tools. Since it's so easy to push code around, copy paste and hack-until-it-fits approach is encouraged.

But I'd simply distance myself from referencing that code as problematic with regard to your proposal. You're looking for solution in the wrong place.

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
11

• 12
• 16
• 9
• 14
• 10
• Forum Statistics

• Total Topics
632658
• Total Posts
3007687
• Who's Online (See full list)

There are no registered users currently online

×