473,785 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

proper programming? (events)

hi ,

ok , i have a programming background but i'm new to C# . i'm also self
taught so :

i have a datagridview that should act differently depending on which
user has signed in

now is it more effecient/correct if i do this:

if(user=="user1 ") {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows. Forms.DataGridV iewCellCancelEv entHandler(this .dataGridView2_ CellBeginEdit_U ser1);
}else {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows. Forms.DataGridV iewCellCancelEv entHandler(this .dataGridView2_ CellBeginEdit_U ser2);
}

as opposed to check for which user in ONE cellBegin event??

Thanks
Gideon

Nov 17 '06 #1
11 1677

giddy wrote:
hi ,

ok , i have a programming background but i'm new to C# . i'm also self
taught so :

i have a datagridview that should act differently depending on which
user has signed in

now is it more effecient/correct if i do this:

if(user=="user1 ") {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows. Forms.DataGridV iewCellCancelEv entHandler(this .dataGridView2_ CellBeginEdit_U ser1);
}else {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows. Forms.DataGridV iewCellCancelEv entHandler(this .dataGridView2_ CellBeginEdit_U ser2);
}

as opposed to check for which user in ONE cellBegin event??

Thanks
Gideon
I'm not sure I like either method. Checking for the actual user would
seem to make things pretty hard to maintain. What kinds of things are
you looking to do different? There is almost certainly a better way to
accomplish what you want...

--
Tom Shelton

Nov 17 '06 #2
Hi Gideon,

I prefer to place that logic in the event handler, or if the logic is complex
and dynamic then a business object. i.e., if the logic in the event handler
may be configured for each user and changed at a later time based on database
properties, for example, then that complexity may warrant the use of a more
complex system as well to prevent code bloat in the event handler method and
to encapsulate the logic so it can be reused in other UI components and
systems.

Here's a simple BO model that you might want to adopt if you have "dynamic"
needs, such as the one I mentioned above:

this.dataGridVi ew2.CellBeginEd it += dataGridView2_C ellBeginEdit;

void dataGridView2_C ellBeginEdit(ob ject sender, SomeEventArgs e)
{
// you should ensure that your application assigns the User.Current
// property before it is queried here, or you can make the property a
// singleton field and initialize it automatically upon first request
using a
// type constructor (static).

User.Current.Be ginCellEdit(sen der, e);
}
class User
{
private static User current;
public static User Current { get { return current; } set { current=
value; } }

public UserUICapabilit ies Caps { get { return caps; } }

private readonly UserUICapabilit ies caps;
private readonly int id;

public User(int id)
{
this.id = id;
caps = new UserUICapabilit ies(this);
}

public void BeginCellEdit(o bject sender, SomeEventArgs e)
{
caps.BeginCellE dit(sender, e);
}
}

class UserUICapabilit ies
{
private readonly User user;
private bool initialized; // lazy initialization

public UserUICapabilit ies(User user)
{
this.user = user;
}

void EnsureInitializ ed()
{
if (initialized)
return;

// TODO: load user caps from database

initialized = true;
}

public void BeginCellEdit(o bject sender, SomeEventArgs e)
{
EnsureInitializ ed();

// Each User object with a distinct "id" will have an
// instance of a UserCapabilitie s object that can provide a
// different implementation here.

// TODO: begin cell edit based on the "user" field in this class
}
}
If the BeginCellEdit method needs more information about the UI elements that
it can manipulate, then you can create a data context class. An instance of
your data context class may be passed to BeginCellEdit instead of the sender
and event args:

class BeginCellEditCo ntext
{
private DataGridView grid;
private DataGridView Grid { get { return grid; } }

private Label label;
private Label Label { get { return label; } }

public BeginCellEditCo ntext(DataGridV iew grid, Label label)
{
this.grid = grid;
this.label = label;
}
}

That class may be the only argument to the BeginCellEdit method:

public void BeginCellEdit(B eginCellEditCon text context) { ... }

The method may be called as such:

BeginCellEditCo ntext context = new BeginCellEditCo ntext(theGrid, theLabel);

User.Current.Be ginCellEdit(con text);
Another option is to use an MVP architecture, but that's going to add even
more complexity. You'll have to create command objects for every possible
task that the BeginCellEdit method may perform.

The simplest approach that meets all your needs will be the best one; in some
cases that is just a simple event handler routine, so choose wisely :)

--
Dave Sexton

"giddy" <gi*******@gmai l.comwrote in message
news:11******** **************@ j44g2000cwa.goo glegroups.com.. .
hi ,

ok , i have a programming background but i'm new to C# . i'm also self
taught so :

i have a datagridview that should act differently depending on which
user has signed in

now is it more effecient/correct if i do this:

if(user=="user1 ") {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows. Forms.DataGridV iewCellCancelEv entHandler(this .dataGridView2_ CellBeginEdit_U ser1);
}else {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows. Forms.DataGridV iewCellCancelEv entHandler(this .dataGridView2_ CellBeginEdit_U ser2);
}

as opposed to check for which user in ONE cellBegin event??

Thanks
Gideon

Nov 17 '06 #3
oops. .i'm sorry , by user i meant user for my application , my app
mantains users wth passwords , i'm not talking about windows user
accounts

basically i did'nt want to make it confusing but , there are levels ...
each user is given some privilege and retricted in some way , eg .
some users might not be allowed to edit , but only allowed make new
entries , some users would be allowed do the opposite.. etc... .the
celBeginedit is'nt the only event i have to check for this...

i'm just asking if its CORRECT to give it a different delegate to
different funciton depending on what privelages the use has...

becuase checking for it in ONE event might get cumbersome and reduce
efficency??

also is Program.cs file , with "class program , and the main()" the
place to have complete global variables? that can be accessed by all
forms and dialogs??? (i'm an ex vb! , so i'm asking is program.cs like
a module file?)

Gideon

Tom Shelton wrote:
I'm not sure I like either method. Checking for the actual user would
seem to make things pretty hard to maintain. What kinds of things are
you looking to do different? There is almost certainly a better way to
accomplish what you want...
Nov 17 '06 #4
Hi Gideon,

<snip>
basically i did'nt want to make it confusing but , there are levels ...
each user is given some privilege and retricted in some way , eg .
some users might not be allowed to edit , but only allowed make new
entries , some users would be allowed do the opposite.. etc... .the
celBeginedit is'nt the only event i have to check for this...
In that case, the code I posted in my original response should be useful to
use as the foundation for a User business object to encapsulate information
about a particular user, and a UserUICapabilit ies object that encapsulates a
User's permissions. You may even want to use roles that encapsulate groups of
permissions so that you can write code as such the following:

if (User.Current.I sAdministrator) // role-check
{
// do admin things such as allow edit AND decrypt related information
}
else if (User.Current.C anEdit) // permission-check for non-admins
{
// allow edit
}
i'm just asking if its CORRECT to give it a different delegate to
different funciton depending on what privelages the use has...
For the example you posted, I wouldn't recommend it at all. As I already
stated, I think that logic should be in the event handler (or better yet, be
abstracted into a business object).
becuase checking for it in ONE event might get cumbersome and reduce
efficency??
The same would be true in the method that checks the user name to determine
which delegate to be registered as an event handler.

Try to separate the UI logic from the business logic. That is, encapsulate
the business logic in separate components that can be utilized by the UI code.
Only provide one place to handle a UI event, and then perform the required
processing in the appropriate business object. If the process itself will
vary by state that is retrieved from a database, such as user permissions,
then this design approach will make it much easier for you to change things in
the future without having to change the business logic in all of the UI
classes in which it may have been hard-coded. This is especially true if you
code the logic as in your example, where you wrote:
if (user == "user1")
What happens if "user1" is renamed to "user_1", or deleted, or their
permissions are changed?

In that case, you'd have to recompile your code to handle the change in the
data. That's something that should by dynamic, and accounted for ahead of
time so that simple changes in data will not require the entire solution to be
modified and redeployed.

Business objects can be the first step to providing the abstraction you need
from your UI code to your business logic code so that you don't have to
hard-code user names, permissions and business logic in every event handler in
which it's required.
also is Program.cs file , with "class program , and the main()" the
place to have complete global variables? that can be accessed by all
forms and dialogs??? (i'm an ex vb! , so i'm asking is program.cs like
a module file?)
Try to use as little global variables as possible. Instead, try to think more
OOP.

That said, there are definitely times where a global variable might be of use
outside of any business object, but it's rare (if even appropriate at all).

But I do use the Program class in my projects to aggregate certain singleton
data such as the current user of the application or the current client context
in which all of the Forms in my application will process information across
the entire system, for example:

static class Program
{
public static User CurrentUser { get { return User.Current; } }
public static Client CurrentClient { get { return Client.Current; }
}

But realize that the Program class doesn't store the data in this case, it
just creates a common interface for accessing global data. The data itself is
stored in the appropriate business object. In some cases, a DataContext
object may be useful if you need to store multiple contexts, simultaneously.

I like using the Program class because it just feels natural to code against
data with application scope like this:

if (Program.Curren tUser.IsAdminis trator)
{
if (Program.Curren tClient.Invoice Required)
{
Invoice invoice = Invoice.Prepare Invoice(Program .CurrentClient) ;
}
}

This is really just a matter of opinion. Some people, I'm sure, prefer to
access the User and Client objects directly for singleton data. I just feel
that User.Current isn't as clear as Program.Current User.

--
Dave Sexton
Nov 17 '06 #5
PS

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uK******** ******@TK2MSFTN GP04.phx.gbl...
Hi Gideon,

I prefer to place that logic in the event handler, or if the logic is
complex and dynamic then a business object. i.e., if the logic in the
event handler may be configured for each user and changed at a later time
based on database properties, for example, then that complexity may
warrant the use of a more complex system as well to prevent code bloat in
the event handler method and to encapsulate the logic so it can be reused
in other UI components and systems.

Here's a simple BO model that you might want to adopt if you have
"dynamic" needs, such as the one I mentioned above:

this.dataGridVi ew2.CellBeginEd it += dataGridView2_C ellBeginEdit;

void dataGridView2_C ellBeginEdit(ob ject sender, SomeEventArgs e)
{
// you should ensure that your application assigns the User.Current
// property before it is queried here, or you can make the property a
// singleton field and initialize it automatically upon first request
using a
// type constructor (static).

User.Current.Be ginCellEdit(sen der, e);
}
You make some very good points Dave. When it comes to authorizations it is
also possible to have a heirarchy of view/add/edit/delete. I often split the
responsibilitie s between how the events are hooked up from what is handled
in the event handler. If a user's authorization is read only then I usually
do not hook up any events and make the control read only. The event handler
is used for when the user has some editing authorizations.

In some respects the OP's delegation to different event handlers at "load"
time is a halfway between using a single event handler that handles
different levels of authorizations, and using a separate business object
that delgates accordingly. He has just shifted the delegation decision to
"before" the event has occured.

PS
>
class User
{
private static User current;
public static User Current { get { return current; } set { current=
value; } }

public UserUICapabilit ies Caps { get { return caps; } }

private readonly UserUICapabilit ies caps;
private readonly int id;

public User(int id)
{
this.id = id;
caps = new UserUICapabilit ies(this);
}

public void BeginCellEdit(o bject sender, SomeEventArgs e)
{
caps.BeginCellE dit(sender, e);
}
}

class UserUICapabilit ies
{
private readonly User user;
private bool initialized; // lazy initialization

public UserUICapabilit ies(User user)
{
this.user = user;
}

void EnsureInitializ ed()
{
if (initialized)
return;

// TODO: load user caps from database

initialized = true;
}

public void BeginCellEdit(o bject sender, SomeEventArgs e)
{
EnsureInitializ ed();

// Each User object with a distinct "id" will have an
// instance of a UserCapabilitie s object that can provide a
// different implementation here.

// TODO: begin cell edit based on the "user" field in this class
}
}
If the BeginCellEdit method needs more information about the UI elements
that it can manipulate, then you can create a data context class. An
instance of your data context class may be passed to BeginCellEdit instead
of the sender and event args:

class BeginCellEditCo ntext
{
private DataGridView grid;
private DataGridView Grid { get { return grid; } }

private Label label;
private Label Label { get { return label; } }

public BeginCellEditCo ntext(DataGridV iew grid, Label label)
{
this.grid = grid;
this.label = label;
}
}

That class may be the only argument to the BeginCellEdit method:

public void BeginCellEdit(B eginCellEditCon text context) { ... }

The method may be called as such:

BeginCellEditCo ntext context = new BeginCellEditCo ntext(theGrid,
theLabel);

User.Current.Be ginCellEdit(con text);
Another option is to use an MVP architecture, but that's going to add even
more complexity. You'll have to create command objects for every possible
task that the BeginCellEdit method may perform.

The simplest approach that meets all your needs will be the best one; in
some cases that is just a simple event handler routine, so choose wisely
:)

--
Dave Sexton

"giddy" <gi*******@gmai l.comwrote in message
news:11******** **************@ j44g2000cwa.goo glegroups.com.. .
>hi ,

ok , i have a programming background but i'm new to C# . i'm also self
taught so :

i have a datagridview that should act differently depending on which
user has signed in

now is it more effecient/correct if i do this:

if(user=="user 1") {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows .Forms.DataGrid ViewCellCancelE ventHandler(thi s.dataGridView2 _CellBeginEdit_ User1);
}else {
this.dataGridVi ew2.CellBeginEd it += new
System.Windows .Forms.DataGrid ViewCellCancelE ventHandler(thi s.dataGridView2 _CellBeginEdit_ User2);
}

as opposed to check for which user in ONE cellBegin event??

Thanks
Gideon

Nov 17 '06 #6
Hi,
You make some very good points Dave. When it comes to authorizations it is
also possible to have a heirarchy of view/add/edit/delete. I often split the
responsibilitie s between how the events are hooked up from what is handled
in the event handler. If a user's authorization is read only then I usually
do not hook up any events and make the control read only. The event handler
is used for when the user has some editing authorizations.
Agreed. It definitely makes sense to disable or even remove a control based
on the current user, but in some cases it's just not that simple. I assumed
that this is one of those not-so-simple cases since the OP didn't mention if
certain users would be restricted from editing all data or just certain cells.
In some respects the OP's delegation to different event handlers at "load"
time is a halfway between using a single event handler that handles
different levels of authorizations, and using a separate business object
that delgates accordingly. He has just shifted the delegation decision to
"before" the event has occured.
Yes, and I don't think that's a reasonable option.

The event is going to occur no matter what, so adding that logic to choose
which handler is invoked is not a clear separation of UI logic and business
logic unless another class handled the delegation for the UI component, but
that would be extra work with no apparent value. What do you think?

--
Dave Sexton
Nov 17 '06 #7
PS

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:eV******** ******@TK2MSFTN GP02.phx.gbl...

<snipped />
>
>In some respects the OP's delegation to different event handlers at
"load" time is a halfway between using a single event handler that
handles different levels of authorizations, and using a separate business
object that delgates accordingly. He has just shifted the delegation
decision to "before" the event has occured.

Yes, and I don't think that's a reasonable option.

The event is going to occur no matter what, so adding that logic to choose
which handler is invoked is not a clear separation of UI logic and
business logic unless another class handled the delegation for the UI
component, but that would be extra work with no apparent value. What do
you think?
I am always in two minds over the "separation " aspect. On simple forms I
find that the code behind provides sufficient separation. I generally have a
setup region, a display region and an event handling region. There is very
little that can be shifted to another object because so much involves an
interaction between a UI object and a business object. e.g.

this.deleteEmpl oyeeButton.Enab led = user.Role.IsAdm inUser;

Moving this to a seperate object is "extra work with no apparent value". In
fact the new object ends up looking like your code behind file did. It is
just a facade that adds no value.

At a certain point a form goes beyond these simple UI object / business
object interactions. Decisions about UI state become more complicated. UI
controls need to react to the events raised by the use of other UI controls.
UI controls may be disabled if the user does not have authorization, if the
business object is read only, if a particular tab is not selected etc. This
is when I use a separate object. The code behind remains simple and the form
once again returns to simple UI control / object interaction, e.g.
this.deleteEmpl oyeeButton.Enab led = myObject.Employ eeDeletionAllow ed;

PS

Nov 17 '06 #8
Hi,

<snip>
I am always in two minds over the "separation " aspect. On simple forms I
find that the code behind provides sufficient separation. I generally have a
setup region, a display region and an event handling region. There is very
little that can be shifted to another object because so much involves an
interaction between a UI object and a business object. e.g.

this.deleteEmpl oyeeButton.Enab led = user.Role.IsAdm inUser;

Moving this to a seperate object is "extra work with no apparent value". In
fact the new object ends up looking like your code behind file did. It is
just a facade that adds no value.
In this simple case, I would agree. The standard MVC architecture used in
WinForms is common and simple to understand.

Here, you're performing an action that could easily be done using the standard
property-binding mechanism. Once binding is no longer a possibility, I
believe that complexity may warrant abstraction.
At a certain point a form goes beyond these simple UI object / business
object interactions. Decisions about UI state become more complicated. UI
controls need to react to the events raised by the use of other UI controls.
UI controls may be disabled if the user does not have authorization, if the
business object is read only, if a particular tab is not selected etc. This
is when I use a separate object. The code behind remains simple and the form
once again returns to simple UI control / object interaction, e.g.
this.deleteEmpl oyeeButton.Enab led = myObject.Employ eeDeletionAllow ed;
I agree, but in this example you still only need to set an Enabled property.
That could be done using simple property-binding.

My example allowed for complex business logic on the UI components through a
"capabiliti es" class. It is not an appropriate design if the OP only needs
the simplicity in your examples, but I tried to make that clear in my original
response. Since the OP didn't state the requirements in detail, I assumed
that they may be complex enough where giving an answer such as, "put it in the
event handler" might have been too basic.

I think we agree here, though, that the standard MVC architecture in WinForms
may still be appropriate in certain circumstances.

Do we also agree that coding the logic to choose an appropriate event handler
instead of having a single event handler, in the OP's particular case, is a
bad idea? (that was actually my original question to you :)

--
Dave Sexton
Nov 17 '06 #9
PS

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:uM******** ******@TK2MSFTN GP06.phx.gbl...
Hi,

<snip>
>I am always in two minds over the "separation " aspect. On simple forms I
find that the code behind provides sufficient separation. I generally
have a setup region, a display region and an event handling region. There
is very little that can be shifted to another object because so much
involves an interaction between a UI object and a business object. e.g.

this.deleteEmp loyeeButton.Ena bled = user.Role.IsAdm inUser;

Moving this to a seperate object is "extra work with no apparent value".
In fact the new object ends up looking like your code behind file did. It
is just a facade that adds no value.

In this simple case, I would agree. The standard MVC architecture used in
WinForms is common and simple to understand.

Here, you're performing an action that could easily be done using the
standard property-binding mechanism. Once binding is no longer a
possibility, I believe that complexity may warrant abstraction.
A good guideline to use.
>
>At a certain point a form goes beyond these simple UI object / business
object interactions. Decisions about UI state become more complicated. UI
controls need to react to the events raised by the use of other UI
controls. UI controls may be disabled if the user does not have
authorizatio n, if the business object is read only, if a particular tab
is not selected etc. This is when I use a separate object. The code
behind remains simple and the form once again returns to simple UI
control / object interaction, e.g. this.deleteEmpl oyeeButton.Enab led =
myObject.Emplo yeeDeletionAllo wed;

I agree, but in this example you still only need to set an Enabled
property. That could be done using simple property-binding.
Yes, but the logic required to work out if the button should be enabled is
something that should be encapsulated outside of the code behind in it's own
object. I guess I use the Mediator pattern.

"Define an object that encapsulates how a set of objects interact. Mediator
promotes loose coupling by keeping objects from referring to each other
explicitly, and it lets you vary their interaction independently"
>
My example allowed for complex business logic on the UI components through
a "capabiliti es" class. It is not an appropriate design if the OP only
needs the simplicity in your examples, but I tried to make that clear in
my original response. Since the OP didn't state the requirements in
detail, I assumed that they may be complex enough where giving an answer
such as, "put it in the event handler" might have been too basic.

I think we agree here, though, that the standard MVC architecture in
WinForms may still be appropriate in certain circumstances.

Do we also agree that coding the logic to choose an appropriate event
handler instead of having a single event handler, in the OP's particular
case, is a bad idea? (that was actually my original question to you :)
I would have to agree with you on that. If the OP wants to use separate
methods then he should call them from the single event handler.

Good discussion,

Regards,

PS
>
--
Dave Sexton

Nov 17 '06 #10

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

Similar topics

16
2159
by: Feico | last post by:
Dear friends I am an experienced programmer, but I happen to have MS Access, which uses a language unknown to me. I want to perform an operation on all record on a table, like this For recordnumber=1 to NumberOfElements(Tabel) PerformCalculation(recordnumber.fieldname)
6
5052
by: Martin Ortiz | last post by:
Which is best approach? Should Try + Catch be used to only deal with "catastrophic" events (like divide by zero, non-existant file, etc...etc...) Or should Try + Catch be used IN PLACE of regular defensive programming? (ie if file exists do this, if not do something else) Or should Try + Catch be used TO SUPPLAMENT regular defensive programming?
26
4857
by: I_AM_DON_AND_YOU? | last post by:
This is the scenario: I have a VB.Net project comprising of a few Forms. On Form1 I have more than 20 buttons. There is a very lenghty code written in click event of each and every button. Right now I haven't used any sub procedure. I mean to say I am writing the code directly in the click event. So it's become very lengthy and therefore to figure out some problem or make any changes I have to scroll at lot. Also in addition to click...
6
1945
by: Ricky W. Hunt | last post by:
It's dawning on my a lot of my problems with VB.NET is I'm still approaching it in the same way I've programmed since the late 70's. I've always been very structured, flow-charted everything, used subroutines, etc. Now I'm trying to study this new way and I'm getting some terms confused and can find no clear definition (some even overlap or use two different words for the same thing, even when they are actually different). I'm reading a...
6
1872
by: Luke Vogel | last post by:
Hi all ... could someone point me in the right direction for programming office applications (specifically excel) using vb.net? Can vb.net replace or enhance VBA that comes with the office suite? cheers... have a great Christmas all! -- Regards Luke. ----- There are 10 types of people in this world
4
1528
by: Jon Slaughter | last post by:
When programming, say, a control should I use the objects of the control directly, reference them from this, or use, if possible, the ones passed through event arguments? e.g., in a paint event I can use this. or just access the fields and methods of the control directly or use the painteventargs argument passed. Say I want to draw a line on the control. What I'm a little confused about is when to use "this.". I know its mainly used...
15
2035
by: Jason Doucette | last post by:
If you have two overloaded functions: double maximum(double a, double b, double c); int maximum(int a, int b, int c); They work fine if you call maximum() with all arguments as doubles, or all as ints. But, if you mix up doubles with ints in the argument list, it doesn't know which maximum() to call... but only one could possibly match -- the one that takes doubles.
0
11355
MMcCarthy
by: MMcCarthy | last post by:
VBA is described as an Event driven programming language. What is meant by this? Access, like most Windows programs, is an event driven application. This means that nothing happens unless it is in response to some event that has been detected by the application. The steps are fairly straightforward: An event happens The event is detected by the application The application responds to the eventThe Windows OS will automatically detect...
43
3698
by: Adem24 | last post by:
The World Joint Programming Language Standardization Committe (WJPLSC) hereby proclaims to the people of the world that a new programming language is needed for the benefit of the whole mankind in the 21st millenium. This new language not only differs from existing ones by new features and paradigms but which also brings real advantage by rigourously preventing bad programmer habits by omitting features which are outdated. In the proposed...
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.