|
The car is fine, except for one nut behind the wheel.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I really like this analogy and I will steal it for my article. However argument is that encapsulation eventually doesn't solve the problem its meant to solve and it's flawed. I know it's controversial, but after some research, I found out I am not the only one who got to this conclusion Object-Oriented Programming: A Disaster Story – Brian Will – Medium[^]. The controversial part is that people can argue that Encapsulation does its job (like in the case of the car), but OOP doesn't help, with its flexibility, to not break the car. If I can break the car easily, what's the point of the encapsulation to start with? Of course Encapsualtion as hiding of complexity is absolutely valid. Hence I think this problem I am trying to formalise, which is the possibility to set a valid state at the wrong time, may need another name. I will link the article here before to make it public, as I'd like your feedback.
modified 20-Jan-19 10:34am.
|
|
|
|
|
I think you intended this reply for Carlo. If I mention @CPallini here, he should be alerted.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Peter and @CPallini, I know it's a long shot, but if you have 10 minutes to read a first draft of my article, I would like to know if it makes sense to you and in this case give me some feedback.
The Quest for Maintainable Code and The Path to ECS - Seba's Lab[^]
password: readme.
I don't want this article to be too abstract, I know that I assume that people know what ECS is (It's not an article about explaining it), but nevertheless I need to know if I face things so abstractly that is hard to see how they are applied in real life. I will gather more significant anecdotes before to publish it.
|
|
|
|
|
What you are dealing with is called reaction programming .. your object needs to react to things .. anything from collisions to just communicating when asked.
It's well described here along with the usual 3 ways to deal with it
Reactive programming - Wikipedia[^]
Now take care Object-oriented Reactive Programming is not Reactive Object-oriented Programming there is a big difference between those two you need to decide which you are doing and the difference between them.
From what you said I think what you are after is
Observer pattern - Wikipedia[^]
The Observer pattern addresses the following problems:
- A one-to-many dependency between objects should be defined without making the objects tightly coupled.
- It should be ensured that when one object changes state an open-ended number of dependent objects are updated automatically.
- It should be possible that one object can notify an open-ended number of other objects.
Now in programmer jargon speak we call observer pattern programming as "Omnipotent god programming" because there will exist an object or function that observes and controls everything. It is often used in games programming but it is not well suited to real world situations where you can't encapsulate all options and you need to "think" about what is going on.
As an example DNS attacks on websites work because they break the observer pattern of the internet standards .. to deal with the attack you need to know past history and apply some logic
In vino veritas
modified 20-Jan-19 1:05am.
|
|
|
|
|
What are the programmers' opinions about Plain English Programming?
Plain English Programming is useful?
If not, why Plain English Programming is not useful?
Reference: www.osmosian.com
Moderators, if this place is not the correct place for this topic, please move this topic.
modified 18-Jan-19 15:29pm.
|
|
|
|
|
Quantum Robin wrote:
Reference: www.osmosian.com Wasn't the owner of this shunned here many years ago?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Computer languages encapsulate precise physical concepts, english language encapsulates wide range communication.
It is never the language describing a problem that is the issue it is describing the process in terms of a physical concept the CPU can execute as code blocks.
For perspective you could write a book claiming all you need is a screwdriver, spanner and hammer as tools and you can fix anything. Whilst you can probably tackle a vast range of repairs there are jobs that require highly specialized tools that you simply couldn't do. Plain English Programming falls into the same fallacy you conceive situations it might work but you have to close your eyes to the situations it clearly won't.
I suspect the only way to really go after a real concept of english language programming would be via AI and if you went that path specific jargon would be less verbose, clearer and not prone to stupid English language nuances. Take any scientific field the first thing we generally have to do is butcher English into a series of defined jargon and acronyms so we can all agree on what is being said. Read any science journal or book and it isn't english a layman would recognize you need to know what all the jargon and acronyms mean. So I put the chances of any serious programming in english language at close to zero because we can't even do it with science.
In vino veritas
|
|
|
|
|
On top of everything leon already said, natural languages are too ambiguous to be used as a computer language. The exact meaning of everything you say depends on the context as much as who you're talking to, and often can only be interpreted correctly when also analyzing your gestures and mimics. A simple wink in the context of some statement could mean a world of a difference.
This is the main reason why we misunderstand each other so often in written communication.
Given that high chance of misunderstanding, I'd rather not use a software system that is prone to doing something entirely different than what I intended. If I tell it to "Go to hell" I do not want it to query TomTom for directions. And if I tell it to "Let's eat grandpa!", I better not forget that all-important comma: "Let's eat, grandpa!"
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
It's been done. It's called COBOL.
|
|
|
|
|
With Win32 API ( SetWindowsHookExA + WH_MOUSE_LL ) and ( SetWindowsHookExA + WH_KEYBAORD_LL ) I can recognize a mouse or keyboard event.
But how can I recognize MultiTouch Event on Windows 10?
|
|
|
|
|
|
|
I have MDI MFC application. For a particular child window, i want to split in to two. Already i have toolbar for topview by using OnCreate() in ChildFrame.cpp. I want to add toolbar for bottom view also.
ChildFrame OnCreateClient() code:
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if(iWindowNumber == 4)
{
CRect cr;
GetClientRect( &cr);
if (!m_wndSplitter.CreateStatic(this, 2, 1))
return FALSE;
if(!m_wndSplitter.CreateView(0,0, RUNTIME_CLASS(CTrendView),CSize(cr.Width(), cr.Height()-200),pContext)||
!m_wndSplitter.CreateView(1,0, RUNTIME_CLASS(CTrendListView),CSize(cr.Width(), cr.Height()-550),pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
return TRUE;
}
return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
In OnCreate(), im loading toolbar, but it adds only for TopView. I want to add different toolbar for bootmView. Can we add toolbar using CView::OnCreate()? i tried this but it is not happening.
Otherwise i have to create 3 splitter window, middle winodw will have toolbar buttons that can be added using CMiddleView::OnCreate().
How can i get that?
Anu
|
|
|
|
|
|
In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
struct tagSIZE butSize,bmpSize;
bmpSize.cx = 25;bmpSize.cy = 23;butSize.cx = 35;butSize.cy = 30;
if(iWindowNumber == 4)
{
if (!m_wndWindowTool.Create(this,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|WS_VISIBLE | CBRS_FLOAT_MULTI) ||
!m_wndWindowTool.LoadBitmap(IDB_GROUPVW) ||
!m_wndWindowTool.SetButtons(CtrlGrp,
sizeof(CtrlGrp)/sizeof(UINT)))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
m_wndWindowTool.SetWindowText("Trend");
m_wndWindowTool.SetSizes( butSize,bmpSize );
m_wndWindowTool.SetHeight( 40 );
CRect rect;
m_wndWindowTool.GetItemRect(0, &rect);
m_wndWindowTool.m_Static.IsTitle = true;
if (!m_wndWindowTool.m_Static.Create("Title",WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,rect, &m_wndWindowTool, IDD_TITLESTATIC) )
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
}
}
Anu
|
|
|
|
|
Anu_Bala wrote: In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.
Did you read the article?
Did you download the code to test/debug it to know how it works?
|
|
|
|
|
I saw that one show CFrameWnd. My window is CMDIChildWnd. So i didnt try first. I tried now. i create CSPlitFrame as CFrameWnd and i coded like below. But when i want my particular window , it shows error on calling that view in Mainframe.cpp.
BEGIN_MESSAGE_MAP(CSplitFrame, CFrameWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()
BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT , CCreateContext* pContext)
{
CTrendListView *pview;
CCreateContext context;
pContext = &context;
pContext->m_pNewViewClass = RUNTIME_CLASS(CTrendListView);
pview = (CTrendListView *) CreateView(pContext, AFX_IDW_PANE_FIRST);
if (pview == NULL)
return FALSE;
SetActiveView(pview, FALSE);
return TRUE;
}
int CSplitFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndWindowTool.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndWindowTool.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; }
m_wndWindowTool.EnableDocking(CBRS_ALIGN_ANY);
m_wndWindowTool.SetBorders(3, 3, 3, 3);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndWindowTool);
return 0;
}
CChildFrame.cpp OnCreateClient()
if (!m_wndSplitter.CreateStatic(this, 2, 1))
return FALSE;
if(!m_wndSplitter.CreateView(0,0, RUNTIME_CLASS(CTrendView),CSize(cr.Width(), cr.Height()-200),pContext)||
!m_wndSplitter.CreateView(1,0, RUNTIME_CLASS(CSplitFrame),CSize(cr.Width(), cr.Height()-550),pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
But it shows error in calling TrendView()
if( pTrendDisplayFrame == NULL )
{
iWindowNumber = 4;
CDocTemplate *pTemplate = theApp.pTrendViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL ); if( pTrendDisplayFrame == NULL )
{
MessageBox( "Unable to Create Trend Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
}
else
MDIActivate( pTrendDisplayFrame );
When i create SplitFrame as MDICHildWnd, it shows assertion error. If my main view (TrendView is MDICHildWnd) and TrendListVIew also MDICHildWnd.
Anu
|
|
|
|
|
Anu_Bala wrote: When i create SplitFrame as MDICHildWnd, it shows assertion error.
Where exactly the Assertion fails?
|
|
|
|
|
If i use
class CSplitFrame : public CframeWnd
Here, I call the TrendView using following fucntion in mainfrm.cpp,
void CMainFrame::OnTrendview()
{
if( pTrendDisplayFrame == NULL )
{
iWindowNumber = 4;
CDocTemplate *pTemplate = theApp.pTrendViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
if( pTrendDisplayFrame == NULL )
{
MessageBox( "Unable to Create Trend Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
}
else
MDIActivate( pTrendDisplayFrame );
}
Here it comes messagebox “Unable to create trend display” becoz pTrendDisplayFrmae is null. Frame is not created in CreateNewFrame(),it return null from this function call from doctempl.cpp
if (!pFrame->LoadFrame(m_nIDResource,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context))
{
TRACE(traceAppMsg, 0, "Warning: CDocTemplate couldn't create a frame.\n");
return NULL;
}
When I use CsplitFrame as MDIChilWNd
class CSplitFrame : public CMDIChildWnd
IT shows assertion error in winmdi.cpp
CMDIFrameWnd* CMDIChildWnd::GetMDIFrame()
{
ASSERT_KINDOF(CMDIChildWnd, this);
ASSERT(m_hWnd != NULL);
HWND hWndMDIClient = ::GetParent(m_hWnd);
ASSERT(hWndMDIClient != NULL);
CMDIFrameWnd* pMDIFrame;
pMDIFrame = (CMDIFrameWnd*)CWnd::FromHandle(::GetParent(hWndMDIClient));
ASSERT(pMDIFrame != NULL);
ASSERT_KINDOF(CMDIFrameWnd, pMDIFrame); ASSERT(pMDIFrame->m_hWndMDIClient == hWndMDIClient);
ASSERT_VALID(pMDIFrame);
return pMDIFrame;
}
My TrendView base class is
class CTrendView : public CView
TrendListView base class is also CView
class CTrendListView : public CView
Im invoking this TrendListView as follow
void CMainFrame::OnTrendListView()
{
iGraphView = 0; if( pTrendListDisplayFrame == NULL )
{
iWindowNumber = 11;
CDocTemplate *pTemplate = theApp.pTrendListViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
if( pTrendListDisplayFrame == NULL )
{
AfxMessageBox( "Unable to Create Tuning Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendListDisplayFrame ,NULL );
}
else
MDIActivate( pTrendListDisplayFrame );
}
When i press Trendpage in main menu, this trend view and trendlistview will display in a same page as splitted window. The window will look like
--------------
Main menu
--------------
Toolbar
-------------
TrendView
--------------
another toolbar
---------------
TrendListview
Anu
modified 17-Jan-19 0:09am.
|
|
|
|
|
Anu_Bala wrote: Im invoking this TrendListView as follow
void CMainFrame::OnTrendListView()
{
iGraphView = 0; if( pTrendListDisplayFrame == NULL )
{
iWindowNumber = 11;
CDocTemplate *pTemplate = theApp.pTrendListViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
if( pTrendListDisplayFrame == NULL )
{
AfxMessageBox( "Unable to Create Tuning Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendListDisplayFrame ,NULL );
}
else
MDIActivate( pTrendListDisplayFrame );
}
What is the theApp.pTrendListViewTemplate?
How is it defined/initialized?
|
|
|
|
|
Are there programmers that are currently using machine code and Assembly?
If yes, why?
If yes, are there many programmers that are currently using machine code and Assembly?
If yes, why?
|
|
|
|
|
I'll take a guess!
Quote: Are there programmers that are currently using machine code and Assembly?
YES.
Quote: If yes, why?
Maybe you want to work in computer security?
Quote: So You Want To Be A Malware Analyst - Malwarebytes Labs | Malwarebytes Labs[^]
In order for a Malware Analyst to be able to read the malware code, they will need to disassemble it. Unfortunately, the highest language derived from binary code is Assembly, which is the last level of human readable code. Therefore, it is imperative that a would-be Malware Analyst, also learn how to read and write Assembly code.
Maybe you want your code to be very efficient (very large program, or very minimal computing resources?).
http://www.agner.org/optimize/optimizing_assembly.pdf
See the 10 or so reasons found here:
Quote: 1.1 Reasons for using assembly code
Assembly coding is not used as much today as previously. However, there are still reasons
for learning and using assembly code. The main reasons are:
Or maybe you are working in an embedded environment...
[Digital Logic design, Assembly Language & Embedded Systems development]
Quote:
If yes, are there many programmers that are currently using machine code and Assembly?
If yes, why?
To each his own?
|
|
|
|
|
Almost forgot one entire category: Reverse Engineering.
|
|
|
|
|
@Member 14088880,
Thanks for the your response!
|
|
|
|
|