C#C
C#4y ago
Kippachu

Making concrete object classes

        private void Initialize_NavigationItems()
        {
            var fooNavigationItem = new NavigationItem
            {
                Header = "Foo",
                Items = new NavigationItemsCollection
                {
                    new()
                    {
                        Header = "Foo task 1",
                        Command = CommandOpenDialog
                    }
                }
            };

            NavigationItems = new NavigationItemsCollection
            {
                fooNavigationItem
            };
        }

Hello, in this example is how I create my navigation items but my question is, instead of having too much logic in my method, isn't simply better if I create a FooNavigationItem and move the logic in it ?
The method would become =>
        private void Initialize_NavigationItems()
        {
            NavigationItems = new NavigationItemsCollection
            {
                new FooNavigationItem()
            };
        }

Thanks
Was this page helpful?