Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to call another function #9

Open
100backslash001 opened this issue Nov 25, 2023 · 2 comments
Open

Function to call another function #9

100backslash001 opened this issue Nov 25, 2023 · 2 comments

Comments

@100backslash001
Copy link

What is the point of the function windowsUpdated? All the function do is just call another function. It seems like it could be removed from the code.

@jaki729
Copy link

jaki729 commented Nov 26, 2023

The windowsUpdated function in your code seems redundant as it's merely calling another function, updateNumberOfCubes(), without performing any additional logic. As it stands, removing windowsUpdated and directly calling updateNumberOfCubes() wherever windowsUpdated() is called would likely simplify the code without losing any functionality.

Sometimes, developers create intermediate functions like windowsUpdated for potential future expansion or to maintain a consistent structure across the codebase. However, if it doesn't serve any clear purpose beyond calling another function and there are no plans for extending its functionality in the future, removing it could indeed streamline the code. Always remember to ensure that removing such functions won't impact other parts of the codebase before doing so.

	function setupWindowManager ()
	{
		windowManager = new WindowManager();
		windowManager.setWinShapeChangeCallback(updateWindowShape);
		windowManager.setWinChangeCallback(windowsUpdated);

		// here you can add your custom metadata to each windows instance
		let metaData = {foo: "bar"};

		// this will init the windowmanager and add this window to the centralised pool of windows
		windowManager.init(metaData);

		// call update windows initially (it will later be called by the win change callback)
		windowsUpdated();
	}

	function windowsUpdated ()
	{
		updateNumberOfCubes();
	}

@jiangjiang2754
Copy link

The windowsUpdated function in your code seems redundant as it's merely calling another function, updateNumberOfCubes(), without performing any additional logic. As it stands, removing windowsUpdated and directly calling updateNumberOfCubes() wherever windowsUpdated() is called would likely simplify the code without losing any functionality.

Sometimes, developers create intermediate functions like windowsUpdated for potential future expansion or to maintain a consistent structure across the codebase. However, if it doesn't serve any clear purpose beyond calling another function and there are no plans for extending its functionality in the future, removing it could indeed streamline the code. Always remember to ensure that removing such functions won't impact other parts of the codebase before doing so.

function setupWindowManager ()
{
	windowManager = new WindowManager();
	windowManager.setWinShapeChangeCallback(updateWindowShape);
	windowManager.setWinChangeCallback(windowsUpdated);

	// here you can add your custom metadata to each windows instance
	let metaData = {foo: "bar"};

	// this will init the windowmanager and add this window to the centralised pool of windows
	windowManager.init(metaData);

	// call update windows initially (it will later be called by the win change callback)
	windowsUpdated();
}

function windowsUpdated ()
{
	updateNumberOfCubes();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants